레이블이 #xu4인 게시물을 표시합니다. 모든 게시물 표시
레이블이 #xu4인 게시물을 표시합니다. 모든 게시물 표시

2020년 10월 26일 월요일

How to Install WordPress with Mairadb(or MySQL) on Ubuntu-20.04

How to Install WordPress with Mairadb(or MySQL) on Ubuntu-20.04


    Environment
      Device :  Odroid-HC2
      OS : Ubuntu-20.04
      HostName : test
      IP : 192.168.101.100
      Pre Insall App : Mairadb(or MySQL), NGINX, PHP


1. Install wordpress


$ sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip php-net-ldap2 php-net-ldap3 php-net-idna2 -y
$ wget https://wordpress.org/latest.zip
$ unzip latest.zip

2. Generate database for wordpress



WordPress
   SQL database : wordpress
   SQL userid : wordpress
   SQL password : test@test

※ Change it to suit your environment

$ sudo mysql -u root
> create database wordpress;
> grant all on wordpress.* to wordpress@localhost identified by 'test@test';
> flush privileges;
> quit;

3. Copy WordPress


$ sudo cp -R wordpress /var/www/html/wp
$ sudo chown  -R www-data:www-data /var/www/html/wp
$ sudo ls /var/www/html/ -l

4. Generate WordPress Initial Setting



WordPress
  SQL database : wordpress
  SQL userid : wordpress
  SQL password : test@test

※ Change it to suit your environment

Connet to WordPress Web (http://192.168.101.100/wp)
Select your Language
Insert your Database Information
Insert your WordPress Infomation
Login your Account
Change your Theme

2020년 10월 15일 목요일

How to Install Windows Fonts on Ubuntu

 How to Install Windows Fonts on Ubuntu


    Environment
      PC1 :
        Device : x64
        OS : Windows10
      PC2 :
        Device : Odroid-HC2(or XU4)
        OS : Ubuntu-20.04





1. Upload Windows Truetype Fonts to Ubuntu


Compressed Fonts Files on Windows
> mkdir TTF
> cd TTF
> copy C:\Windows\Fonts\*.ttf .\TTF\
> copy C:\Windows\Fonts\*.ttc .\TTF\

Compress TTF Folder

Copy Compressed File to Ubuntu

2. Install Truetype Fonts on Ubuntu


$ unzip TTF.zip
$ sudo cp -R TTF /usr/share/fonts/truetype/
$ sudo fc-cache -v -f

How to Install XRDP

 How to Install XRDP


##############################################################

Environment

  Device :  Odroid-HC2(orXU4)

  OS : Ubuntu-20.04

##############################################################





1. Install XRDP


$ sudo install xrdp icewm -y
$ sudo install icewm -y
$ cp /etc/xrdp/startwm.sh /etc/xrdp/startwm.sh.orig
$ nano /etc/xrdp/startwm.sh

Change Configuration

test -x /etc/X11/Xsession && exec /etc/X11/Xsession
exec /bin/sh /etc/X11/Xsession

==>

#test -x /etc/X11/Xsession && exec /etc/X11/Xsession
#exec /bin/sh /etc/X11/Xsession
exec icewm-session


2020년 9월 27일 일요일

How to Install Docker & Kubernetes & LXD on Odroid-HC2 (or XU4)

How to Install Docker & Kubernetes & LXD on Odroid-HC2 (or XU4)


##############################################################

Environment
  Device :  Odroid-HC2
  OS : Ubuntu-20.04

##############################################################






1. Install App

$ sudo apt update
$ sudo apt install apt-transport-https ca-certificates curl gnupg-agent  software-properties-common -y

2. Install Docker

1) Odroid-HC2 (or XU4)

### Install Docker
$ sudo apt install docker docker-compose
$ sudo usermod -aG docker $USER
※ Docker’s Official Repository is not supported

### Test Docker
$ sudo docker run hello-world

2) Odroid-C1

Not Support (Kernel is old)

3) Odroid-C2

### Insert Docker’s official GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
### Verify key
$ sudo apt-key fingerprint 0EBFCD88
### Insert Docker’s Repository
$ sudo add-apt-repository \
   "deb [arch=arm64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
$ sudo apt update
### Install Docker
$ sudo apt install docker-ce docker-ce-cli containerd.io -y
$ sudo usermod -aG docker $USER

### Test Docker

$ sudo docker run hello-world


※ Docker’s Official Repository

○ x86_64
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
○ arm64
$ sudo add-apt-repository \
   "deb [arch=arm64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
○ armhf
$ sudo add-apt-repository \
   "deb [arch=amdhf] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

3. Install Kubernetes

### Insert k8s official GPG key
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
### Insert k8s Repository
$ sudo add-apt-repository "deb https://apt.kubernetes.io/ kubernetes-xenial main"
※ currently bionic & focal is not supported
$ sydo apt update
### Install k8s
$ sudo apt install kubeadm kubelet kubectl kubernetes-cni -y

4. Install LXC & LXD

1) Odroid-HC2 (or XU4)

$ sudo apt install lxd lxd-client -y
$ sudo lxd init
$ sudo usermod -aG lxd $USER $ lxc image list images:

2) Odroid-C1 & C2

Not Support

※ x86_64

$ sudo apt install lxc lxd -y
$ sudo lxd init
$ sudo usermod -aG lxd $USER
$ lxc image list images:


2020년 9월 19일 토요일

How to Install Postfix & Dovecot with MariaDB(or MySQL) on Ubuntu-20.04

How to Install Postfix & Dovecot with MariaDB(or MySQL) on Ubuntu-20.04

##############################################################

Environment

  Device :  Odroid-HC2

  OS : Ubuntu-20.04

  Pre Insalled App : MariaDB(or MySQL)

##############################################################





1. Install Postfix & Dovecot 

$ sudo apt-get install postfix postfix-mysql dovecot-core dovecot-imapd dovecot-lmtpd  dovecot-pop3d dovecot-mysql

$ sudo systemctl restart dovecot

$ sudo netstat -lnp


2. Setup mariadb

##############################################################

##############################################################

database :  mail_server

accout : usermail

password : test@test

host : localhost 

##############################################################

##############################################################


$ sudo mysql -u root -p


### Generate Database for mail

> create database mail_server;

### Generate Acccout for mail

> GRANT SELECT ON mail_server.* TO 'usermail'@'127.0.0.1' IDENTIFIED BY 'test@test';

> flush privileges;

>  GRANT SELECT ON mail_server.* TO 'usermail'@'localhost' IDENTIFIED BY 'test@test';

> flush privileges;


###  Generate Virtual Domain Table

> USE mail_server;

> CREATE TABLE `virtual_domains` (

  `id` INT NOT NULL AUTO_INCREMENT,

  `name` VARCHAR(50) NOT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;


###  Generate Virtual User Table

> CREATE TABLE `virtual_users` (

  `id` INT NOT NULL AUTO_INCREMENT,

  `domain_id` INT NOT NULL,

  `password` VARCHAR(106) NOT NULL,

  `email` VARCHAR(120) NOT NULL,

  PRIMARY KEY (`id`),

UNIQUE KEY `email` (`email`),

FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE

) ENGINE=InnoDB DEFAULT CHARSET=utf8;


###  Generate Virtual Alias Table

> CREATE TABLE `virtual_aliases` (

   `id` INT NOT NULL AUTO_INCREMENT,

   `domain_id` INT NOT NULL,

   `source` varchar(100) NOT NULL,

   `destination` varchar(100) NOT NULL,

    PRIMARY KEY (`id`),

    FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE

) ENGINE=InnoDB DEFAULT CHARSET=utf8;


### Insert Virtual Domain

> INSERT INTO mail_server.virtual_domains

  (`id` ,`name`)

VALUES

  ('1', 'test.com'),

  ('2', 'test.test.com'),

  ('3', 'test'),

  ('4', 'mail.test.com'),

  ('5', 'localhost.test.com'),

  ('6', 'localhost');


### Insert Virtual Mail User

> INSERT INTO `mail_server`.`virtual_users`

  (`id`, `domain_id`, `password` , `email`)

VALUES

  ('1', '1', ENCRYPT('test@test', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))), 'test@test.com'),

  ('2', '1', ENCRYPT('test@test', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))), 'net@test.com'),

  ('3', '1', ENCRYPT('test@test', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))), 'net1@test.com'),

  ('4', '1', ENCRYPT('test@test', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))), 'net2@test.com');


### Insert Virtual Alias

> INSERT INTO `mail_server`.`virtual_aliases`

  (`id`, `domain_id`, `source`, `destination`)

VALUES

  ('1', '1', 'admin@test.com', 'test@test.com'),

  ('2', '1', 'root@test.com', 'test@test.com');


### Check Virtual Table

> SELECT * FROM mail_server.virtual_domains;

> SELECT * FROM mail_server.virtual_users;

> SELECT * FROM mail_server.virtual_aliases;

> quit;


$ sudo systemctl restart mariadb


3. Setup Postfix

### Setup main.cf

$ sudo cp /etc/postfix/main.cf /etc/postfix/main.cf.original

$ sudo nano /etc/postfix/main.cf

Change Configuration

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level=may
=>
smtpd_use_tls = yes
smtpd_tls_cert_file=/etc/dovecot/private/dovecot.pem
smtpd_tls_key_file=/etc/dovecot/private/dovecot.key
smtpd_tls_security_level=may


smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
=>
smtp_use_tls = yes
#smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=may
#smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache


smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
=>
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated,  reject_unauth_destination


mydestination = $myhostname, test.com, ubt64.test.com, localhost.test.com, localhost
=>
mydestination = localhost


Insert Configuration

=>
#Handing off local delivery to Dovecot's LMTP, and telling it where to store mail
virtual_transport = lmtp:unix:private/dovecot-lmtp
#Virtual domains, users, and aliases
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf


### Generate mysql-virtual-mailbox-domains.cf

$ sudo nano /etc/postfix/mysql-virtual-mailbox-domains.cf

user = usermail
password = test@test
hosts = 127.0.0.1
dbname = mail_server
query = SELECT 1 FROM virtual_domains WHERE name='%s'

$ sudo service postfix restart

$ sudo postmap -q test.com mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf


### Generate mysql-virtual-mailbox-maps.cf

$ sudo nano /etc/postfix/mysql-virtual-mailbox-maps.cf

user = usermail
password = test@test
hosts = 127.0.0.1
dbname = mail_server
query = SELECT 1 FROM virtual_users WHERE email='%s'

$ sudo service postfix restart

$ sudo postmap -q test@test.com mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf


### Generate mysql-virtual-alias-maps.cf

$ sudo nano /etc/postfix/mysql-virtual-alias-maps.cf

user = usermail
password = test@test
hosts = 127.0.0.1
dbname = mail_server
query = SELECT destination FROM virtual_aliases WHERE source='%s'

$ sudo service postfix restart

$ sudo postmap -q admin@test.com mysql:/etc/postfix/mysql-virtual-alias-maps.cf


$ sudo nano /etc/postfix/mysql-virtual-alias-maps.cf

user = usermail
password = test@test
hosts = 127.0.0.1
dbname = mail_server
query = SELECT destination FROM virtual_aliases WHERE source='%s'

$ sudo service postfix restart

$ sudo postmap -q admin@test.com mysql:/etc/postfix/mysql-virtual-alias-maps.cf


 

### Setup master.cf

$ sudo cp /etc/postfix/master.cf /etc/postfix/master.cf.orig

$ sudo nano /etc/postfix/master.cf

Change Configuration

#submission inet n       -       y       -       -       smtpd
#  -o syslog_name=postfix/submission
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_tls_auth_only=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
=>
submission inet n       -       y       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_tls_auth_only=yes
#  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o smtpd_helo_restrictions=$mua_helo_restrictions


$ sudo service postfix restart

$ sudo netstat -lnp

check port 25 & 587


5. Setup Dovecot

$ sudo cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.orig

$ sudo cp /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf.orig

$ sudo cp /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/conf.d/10-auth.conf.orig

$ sudo cp /etc/dovecot/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext.orig

$ sudo cp /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.orig

$ sudo cp /etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf.orig


### Setup 10-master.conf

$ sudo nano /etc/dovecot/dovecot.conf

Change Configuration

!include_try /usr/share/dovecot/protocols.d/*.protocol
=>
!include_try /usr/share/dovecot/protocols.d/*.protocol
protocols = imap pop3 lmtp 


### Setup 10-mail.conf

$ sudo nano /etc/dovecot/conf.d/10-mail.conf

Change Configuration

mail_location = mbox:~/mail:INBOX=/var/mail/%u
=>
#mail_location = mbox:~/mail:INBOX=/var/mail/%u
mail_location = maildir:/var/mail/vhosts/%d/%n


mail_privileged_group = mail
=>
mail_privileged_group = mail


### Generate domain per Virtual Host

$ sudo ls -ld /var/mail

$ sudo mkdir -p /var/mail/vhosts/test.com


$ sudo groupadd -g 5000 vmail

$ sudo useradd -g vmail -u 5000 vmail -d /var/mail

$ sudo chown -R vmail:vmail /var/mail


$ sudo nano /etc/dovecot/conf.d/10-auth.conf

Change Configuration

#disable_plaintext_auth = yes
=>
disable_plaintext_auth = yes
auth_mechanisms = plain
=>
auth_mechanisms = plain login
!include auth-system.conf.ext
#!include auth-sql.conf.ext
=>
#!include auth-system.conf.ext
!include auth-sql.conf.ext


$ sudo cp /etc/dovecot/conf.d/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf.ext.orig

$ sudo nano /etc/dovecot/conf.d/auth-sql.conf.ext

Change Configuration

passdb {
  driver = sql
  # Path for SQL configuration file, see example-config/dovecot-sql.conf.ext
  args = /etc/dovecot/dovecot-sql.conf.ext
}
userdb {
  driver = sql
  args = /etc/dovecot/dovecot-sql.conf.ext
}
=>
passdb {
  driver = sql
  # Path for SQL configuration file, see example-config/dovecot-sql.conf.ext
  args = /etc/dovecot/dovecot-sql.conf.ext
}
userdb {
  driver = static
  args = uid=vmail gid=vmail home=/var/mail/vhosts/%d/%n


$ sudo nano /etc/dovecot/dovecot-sql.conf.ext

# Database driver: mysql, pgsql, sqlite
#driver =
=>
# Database driver: mysql, pgsql, sqlite
driver = mysql
#connect =
=>
connect = host=127.0.0.1 dbname=mail_server user=usermail password=test@test
#default_pass_scheme = MD5
=>
default_pass_scheme = SHA512-CRYPT
#password_query = \
#  SELECT username, domain, password \
#  FROM users WHERE username = '%n' AND domain = '%d'
=>
password_query = \
  SELECT email as user, password \
  FROM virtual_users WHERE email='%u'; 


### Change File Owner & Permissions

$ sudo chown -R vmail:dovecot /etc/dovecot

$ sudo chmod -R 771 /etc/dovecot 


### Setup 10-master.conf

$ sudo -i

# nano /etc/dovecot/conf.d/10-master.conf

Change Configuration

service imap-login {
  inet_listener imap {
    #port = 143
  }
  inet_listener imaps {
    #port = 993
    #ssl = yes
  }
}
=>
service imap-login {
  inet_listener imap {
    port = 143
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
}

service pop3-login {
  inet_listener pop3 {
    #port = 110
  }
  inet_listener pop3s {
    #port = 995
    #ssl = yes
  }
}
=>
service pop3-login {
  inet_listener pop3 {
    port = 110
  }
  inet_listener pop3s {
    port = 995
    ssl = yes
  }
}

service lmtp {
  unix_listener lmtp {
    #mode = 0666
  }
=>
service lmtp {
   unix_listener /var/spool/postfix/private/dovecot-lmtp {
    mode = 0600
    user = postfix
    group = postfix
  }




# Change service auth parameter 

  unix_listener auth-userdb {
    #mode = 0666
    #user =
    #group =
  }
=>
  unix_listener auth-userdb {
    mode = 0600
    user = vmail
    #group =
  }
  # Postfix smtp-auth
  #unix_listener /var/spool/postfix/private/auth {
  #  mode = 0666
  #}
=>
  # Postfix smtp-auth
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }

  # Auth process is run as this user.
  #user = $default_internal_user
}
=>
  # Auth process is run as this user.
  #user = $default_internal_user
  user = dovecot
}


# Change service auth-worker parametet

service auth-worker {
  # Auth worker process is run as root by default, so that it can access
  # /etc/shadow. If this isn't necessary, the user should be changed to
  # $default_internal_user.
  #user = root
}
=>
service auth-worker {
  # Auth worker process is run as root by default, so that it can access
  # /etc/shadow. If this isn't necessary, the user should be changed to
  # $default_internal_user.
  user = vmail
}


### Setup 10-ssl.conf

$ sudo nano /etc/dovecot/conf.d/10-ssl.conf

Change Configuration

ssl = yes
=>
ssl = required


ssl_cert = </etc/dovecot/private/dovecot.pem
ssl_key = </etc/dovecot/private/dovecot.key
=>
ssl_cert = </etc/dovecot/private/dovecot.pem
ssl_key = </etc/dovecot/private/dovecot.key


$ sudo systemctl restart dovecot.service

2020년 9월 1일 화요일

How to Install WordPress with Mariadb(or MySQL) on Ubuntu-20.04

 How to Install WordPress with Mariadb(or MySQL) on Ubuntu-20.04


##############################################################

Environment

  Device :  Odroid-HC2

  OS : Ubuntu-20.04

  IP : 192.168.101.100

  Pre Insall App : Mariadb(or MySQL), NGINX, PHP

##############################################################





1. Install WordPress

$ sudo apt install wordpress -y


2. Generate database for WordPress

##############################################################
WordPress 
  SQL database : wordpress
  SQL userid : wordpress
  SQL password : test@test
##############################################################
  
$ sudo mysql -u root
> create database wordpress;
> grant all on wordpress.* to wordpress@localhost identified by 'test@test';
> flush privileges;
> quit;


3. Setup WordPress

$ sudo ln -s /usr/share/wordpress /var/www/html/wp

$ sudo ls /var/www/html/ -l

$ sudo chown -R www-data:www-data /var/www/html/wp

$ sudo chown -R www-data:www-data /var/www/html/wp/

$ sudo ls /var/www/html/ -l

$ sudo ls /var/www/html/wp/ -l

$ sudo cp /var/www/html/wp/wp-config-sample.php /var/www/html/wp/wp-config.php

$ sudo nano /var/www/html/wp/wp-config.php

Change Configuration

define( 'DB_NAME', 'database_name_here' );
=>
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'username_here' );
=>
define( 'DB_USER', 'wordpress' );
define( 'DB_PASSWORD', 'password_here' );
=>
define( 'DB_PASSWORD', 'test@test' );

Insert Configuration

/** Enable Direct Update **/
define('FS_METHOD', 'direct');


$ sudo systemctl restart nginx


4. Connect Web


test@test.com

2020년 8월 31일 월요일

How to Install Openvpn on Ubuntu-20.04

How to Install OpenVPN on Ubuntu-20.04


    Environment
      Device : Odroid-HC2
      OS : Ubuntu-20.04
      Host : test(192.168.101.100/24)
      VPN Network : 10.8.0.0/24


    File Info
      ca.crt : CA(Certificate Authority) crt File
      dh2048.pem : DH(Diffie-Hellman) parameters File
      ta.key : tls-auth key File
      test.key : OpenVPN Server key File
      test.crt : OpenVPN Server crt File
      test.conf : Server Configuration File
      test-1.key : OpenVPN Client-1 key File
      test-1.crt : OpenVPN Client-1 crt File
      test-1.ovpn : OpenVPN Client-1 Configuration File
      test-2.key : OpenVPN Client-2 key File
      test-2.crt : OpenVPN Client-2 crt File
      test-2.ovpn : OpenVPN Client-2 Configuration File



1. Create vpn account


$ sudo adduser vpn
$ sudo nano /etc/group
$ su vpn
$ cd ~

2. Install Openvpn


$ sudo apt install openvpn easy-rsa -y
3. Generate of the CA(Certificate Authority)
$ ls
$ make-cadir easy-rsa
$ ls
$ cd easy-rsa
$ cp vars vars.orig
$ nano vars
Chanage Connfiguration
#set_var EASYRSA_REQ_COUNTRY    "US"
#set_var EASYRSA_REQ_PROVINCE   "California"
#set_var EASYRSA_REQ_CITY       "San Francisco"
#set_var EASYRSA_REQ_ORG        "Copyleft Certificate Co"
#set_var EASYRSA_REQ_EMAIL      "me@example.net"
#set_var EASYRSA_REQ_OU         "My Organizational Unit
==>
set_var EASYRSA_REQ_COUNTRY    "US"
set_var EASYRSA_REQ_PROVINCE   "NY"
set_var EASYRSA_REQ_CITY       "NY"
set_var EASYRSA_REQ_ORG        "TEST"
set_var EASYRSA_REQ_EMAIL      "test@test.com"
set_var EASYRSA_REQ_OU         "TEST"
$ ./easyrsa init-pki
$ ./easyrsa build-ca
$ cp ./pki/ca.crt ~/

4. Generate the server key and certificate request


$ ./easyrsa gen-req test nopass
$ ./easyrsa sign-req server test
$ cp ./pki/private/test.key ./pki/issued/test.crt ~/

5. Generate the DH(Diffie-Hellman) parameters


$ ./easyrsa gen-dh
$ cp ./pki/dh.pem ~/dh2048.pem

6. Generate the tls-auth key (ta.key)


$ openvpn --genkey --secret ta.key
$ cp ./ta.key ~/

7. Setup IP Forward


$ sudo cp /etc/sysctl.conf /etc/sysctl.conf.orig
$ sudo nano /etc/sysctl.conf
Chanage Configuration/h10>
#net.ipv4.ip_forward=1
==>
net.ipv4.ip_forward=1
$ sudo sysctl -p

8. Setup Sever configuration


$ cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz ./
$ gzip -d server.conf.gz
$ cp server.conf test.conf
$ nano test.conf
Chanage Configuration
cert server.crt
key server.key  # This file should be kept secret
==>
cert test.crt
key test.key  # This file should be kept secret
server 10.8.0.0 255.255.255.0
==>
server 10.8.0.0 255.255.255.0
;push "route 192.168.10.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"
==>
push "route 192.168.101.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"
;push "redirect-gateway def1 bypass-dhcp"
==>
push "redirect-gateway def1 bypass-dhcp"
;push "dhcp-option DNS 208.67.222.222"
;push "dhcp-option DNS 208.67.220.220"
==>
push "dhcp-option DNS 192.168.101.210"
push "dhcp-option DNS 8.8.8.8"
;user nobody
;group nogroup
==>
;user nobody
;group nogroup
$ cp test.conf ~/

9. Generate the Client key and certificate request


Generate the Client-1 key and certificate request
$ ./easyrsa gen-req test-1 nopass
$ ./easyrsa sign-req client test-1
$ cp ./pki/issued/test-1.crt pki/private/test-1.key ~/
Generate the Client-2 key and certificate request
$ ./easyrsa gen-req test-2 nopass
$ ./easyrsa sign-req client test-2
$ cp ./pki/issued/test-2.crt pki/private/test-2.key ~/

10. Setup Client configuration



    Environment
      Remote Server : XXX.XXXX.XXX
      Remote Port : YYYY


$ cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf ./
$ cp client.conf ~/test-1.ovpn
$ cp client.conf ~/test-2.ovpn
$ cd ~/
$ nano test-1.opvn
Chanage Configuration
remote my-server-1 1194
==>
remote XXX.XXXX.XXX  YYYY
;user nobody
;group nogroup
==>
;user nobody
;group nogroup
cert client.crt
key client.key
==>
cert test-1.crt
key test-1.key
$ nano test-1.opvn
Chanage Configuration
remote my-server-1 1194
==>
remote XXX.XXXX.XXX  YYYY
;user nobody
;group nogroup
==>
;user nobody
;group nogroup
cert client.crt
key client.key
==>
cert test-2.crt
key test-2.key

11. Activate OpenVPN Server


$ sudo ls /etc/openvpn/
$ sudo cp ca.crt dh2048.pem ta.key test*.* /etc/openvpn/
$ sudo ls /etc/openvpn/
$ sudo systemctl start openvpn@test
$ sudo journalctl -u openvpn@test -xe

12. Install OpenVPN Client


Setup Sever Netawork GW
Copy File to Client
Install OpenVPN App on Client

How to Install NGINX on Ubuntu-20.04

How to Install NGINX on Ubuntu-20.04


    Environment
      Device : Odroid-HC2
      OS : Ubuntu-20.04
      Host : test (192.168.101.100)


1. Install NGINX 


1. Install NGINX


1) Install NGINX
$ sudo apt install nginx -y
$ nginx -v

Connect http://192.168.101.210

2) Install PHP
$ sudo apt install php php-fpm php-mysql -y
$ sudo apt remove apache2 --purge -y
$ sudo rm -rf /etc/apache2
$ sudo netstat -an | grep php
3) Setup NGIX For PHP
$ sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.orig
$ sudo rm /etc/nginx/sites-enabled/default
$ sudo netstat -an | grep php

check php socket

$ sudo nano /etc/nginx/sites-available/default
Insert Configuration
server{

        listen                  80;
        server_name             test.local;
       root /var/www/html;
       index index.html index.htm index.php index.nginx-debian.html;
       location / {
               try_files $uri $uri/ =404;
       }
       location ~ \.php$ {
              fastcgi_pass unix:/run/php/php7.4-fpm.sock;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              include fastcgi_params;
       }
}
$ cd /etc/nginx/sites-enabled/
$ ls -l
$ sudo -i
# cd /etc/nginx/sites-enabled/
# ln -s /etc/nginx/sites-available/default
# ls -l
# exit
$ sudo nano /var/www/html/phpinfo.php
Insert Configuration
<?php
  phpinfo();
?>

Connect http://192.168.101.100/phpinfo.php


2. Install HTTPS service


1) Generate SSL Certification
Generate private key
$ sudo openssl genrsa -des3 -out server.key 2048
Generate CSR(Certification sinning Request)
$ sudo openssl req -new -days 365 -key server.key -out server.csr
Clear password of Private key
$ sudo cp server.key server.key.orig
$ sudo openssl rsa -in server.key.orig -out server.key
Create Certification
$ sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Verify Certification
$ ls -l server.*
$ sudo cat server.key | head -3
$ sudo cat server.crt | head -3
Copy Certification
$ sudo mkdir /etc/nginx/ssl
$ sudo cp ~/server.* /etc/nginx/ssl/
2) Setup NGINX For HTTPS
$ sudo nano /etc/nginx/sites-available/default
Insert Configuration
server{
        listen                  443;
        server_name             test.local;
       root /var/www/html;
       index index.html index.htm index.php index.nginx-debian.html;
        ssl                     on;
        ssl_certificate         /etc/nginx/ssl/server.crt;
        ssl_certificate_key     /etc/nginx/ssl/server.key;
        ssl_protocols           TLSv1 TLSv1.1 TLSv1.2;
       location / {
               try_files $uri $uri/ =404;
       }
       location ~ \.php$ {
              fastcgi_pass unix:/run/php/php7.4-fpm.sock;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              include fastcgi_params;
       }
}

Connect https://192.168.101.100

Connect https://192.168.101.100/phpinfo.php

How To Install MriaDB on Ubunut-20.04

How To Install MriaDB on Ubunut-20.04


    Environment
      Device :  Odroid-HC2 (or XU4)
      OS : Ubuntu-20.04
      Host : test (192.168.101.10)




1. Install MariaDB

$ sudo apt install mariadb-server mariadb-comm mycli python3-mysqldb -y

2. Setup intial mariadb configuration


MariaDB Initial Setup
$ sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
MariaDB Server IP Change
$ sudo cp /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/mariadb.conf.d/50-server.cnf.orig
$ sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Change Configuration
bind-address            = 127.0.0.1
==>
bind-address            = 192.168.101.100

3. Generate Management Account


MriadDB Login
$ sudo mysql -u root -p
Create MariaDB Account
> create user 'test'@'%' identified by 'test@test';
> grant all privileges on *.* to  'test'@'%' with grant option;
> flush privileges;

4. Verify MariaDB


$ mycli -h 192.168.101.100 -u test

How to Install Bind on Ubuntu-20.04

How to Install Bind9 on Ubuntu-20.04 

======================================
Environment
  Device : Odroid-HC2
  OS : Ubuntu-20.04
  Host Name : test
  Domain Name : test.com
======================================




1. Install bind

$ sudo apt install bind9 dnsutils -y


2. Setup bind

1) Setup named.conf.local

$ sudo cp /etc/bind/named.conf /etc/bind/named.conf.orig

$ sudo cp /etc/bind/named.conf.local /etc/bind/named.conf.local.orig

$ sudo nano /etc/bind/named.conf.local

Insert Configuration

zone "test.com" {

        type master;

        file "/etc/bind/db.test.com";

};


2) Setup named.conf.options

$ sudo cp /etc/bind/named.conf.options /etc/bind/named.conf.options.orig

$ sudo nano /etc/bind/named.conf.option


3) Generate named.conf.options

$ sudo nano /etc/bind/db.test.com 

Insert Configuration

; BIND reverse data file for empty rfc1918 zone
;
; DO NOT EDIT THIS FILE - it is used for multiple zones.
; Instead, copy it, edit named.conf, and use that copy.
;
$TTL    86400
@       IN      SOA     test.com. root.test.com. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                          86400 )       ; Negative Cache TTL
;
@       IN      NS      ns.test.com.
@       IN      A       192.168.101.100
@       IN      AAAA    ::1
ns      IN      A       192.168.101.100
test    IN      A       192.168.101.100
net     IN      A       192.168.101.210
net1    IN      A       192.168.101.201
net2    IN      A       192.168.101.202


$ sudo systemctl restart bind9

$ nslookup net.test.com 192.168.101.210


How To Install Ubuntu-20.04 on Odroid-HC2

How To Install Ubuntu-20.04 on Odroid-HC2

======================================
Environment
  Device : Odroid-HC2
  OS : Ubuntu-20.04
  Host : test (192.168.101.100)
======================================

1. Install Ubuntu-20.04 on Odroid-HC2



2. Initial Setup



1) Change default password

$ passwd
$ sudo -i
# passwd

2) Change Network IP

$ sudo nmcli con show
$ sudo nmcli con add con-name "main" ifname  eth0 type ethernet  ip4 192.168.101.100/24 gw4 192.168.101.1
$ sudo nmcli con show
$ sudo nmcli conn delete 'Wired connection 1'

Connet  to new IP

$ sudo cp /etc/NetworkManager/system-connections/main.nmconnection  /etc/NetworkManager/system-connections/main.nmconnection.orig
$ sudo nano /etc/NetworkManager/system-connections/main.nmconnection
Add next config
dns=192.168.101.210;8.8.8.8;
dns-search=ysm.net

3) Change hostname & domainname

$ sudo hostname
$ sudo hostname test
$ sudo hostname
$ sudo cp /etc/hostname /etc/hostname.orig
$ sudo nano /etc/hostname
Change Configuration
odroid
==>
test 
$ sudo cp /etc/hosts /etc/hosts.orig
$ sudo nano /etc/hosts
Change Configuration
127.0.0.1     odroid
==>
127.0.0.1     test test.test.com

::1           localhost ip6-localhost ip6-loopback
==>
::1           test test.test.com localhost ip6-localhost ip6-loopback
$ sudo shutdown -r now

4) Upgrade all package

$ sudo apt update ; sudo apt dist-upgrade -y ; sudo apt autoremove -y

5) Install Bash autocompletion

$ sudo apt install bash-completion -y

6) Generate new Account

$ sudo adduser test
$ sudo cp /etc/group /etc/group.orig
$ sudo nano /etc/group
Change Configuration
odroid
=>
odroid,test

7) Install additional utils

$ sudo apt install mc byobu vlc smplayer xrdp remmina

8) Install resolvconf



$ sudo cat /etc/resolv.conf
$ sudo apt install resolvconf
$ sudo cp /etc/resolvconf/resolv.conf.d/head /etc/resolvconf/resolv.conf.d/head.orig
$ sudo nano /etc/resolvconf/resolv.conf.d/head
Insert Configuration
nameserver 192.168.101.210
nameserver 164.124.101.2

$ sudo cat /etc/resolv.conf

How To Install Docker on Odroid-C2 (or ARM64)

How To Install Docker on Odroid-C2 (or ARM64) Environment Device : Odroid-C2 OS : Ubuntu-20.04 1. Install Dock...