source
First check whether your server supports the device dev/tun
Install OpenVPN
First check whether your server supports the device dev/tun
- # ls -al /dev/net/tun
- You'll get results like the following if it supports
# ls -al /dev/net/tun
crw------- 1 root root 10, 200 Aug 1 14:12 /dev/net/tun
- cat /dev/net/tun
- You'll get results like the following if it is enabled
# cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state
Install OpenVPN
- apt-get update to update the OS
- apt-get install openvpn
- apt-get install openssl
- mkdir /etc/openvpn/easy-rsa to make new directory
- cp -rp /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa to copy the files to the new folder
- cp -rp /usr/share/doc/openvpn/examples/sample-config-files/ /etc/openvpn/sample
- cd /etc/openvpn/easy-rsa/
- vi vars to edit the file named "vars"
- OPTIONAL: Change KEY_SIZE to 2048
- sh vars
- source ./vars to execute vars script
- ./clean-all to remove any previous keys
- ./build-ca to build the certificate authority.
- Press enter for each line it asks to confirm your details, but where it asks for "Common Name" change to your server name
- Type ./build-key-server <server hostname>
- Press enter for fields to confirm and leave the "A challenge password" and "An optional company name" fields blank
- ./build-key <client hostname>
- Press enter again for fields to confirm and leave the "A challenge password" and "An optional company name" fields blank. A different key is needed for each VPN client
- ./build-dh This allows sharing between peers
- cd /etc/openvpn/easy-rsa/keys
- cp <server hostname>.key /etc/openvpn/
- cp <server hostname>.crt /etc/openvpn/
- cp ca.crt /etc/openvpn/
- cp dh1024.pem /etc/openvpn/ or dh2048.pem for 2048 encryption
- cd /etc/openvpn/sample
- gunzip server.conf.gz
- vi server.conf
- Change server.crt to <server hostname>.crt
- Change server.key to <server hostname>.key
- Change "dh1024.pem" to "dh2048.pem" if using 2048 encryption
- Uncomment max-clients 100
- cd /etc/openvpn/sample
- vi client.conf
- change my-server-1 to your IP address of your VPS
- Change "client.crt" to "<client hostname>.crt"
- /etc/openvpn/easy-rsa/keys/<client hostname>.key
- /etc/openvpn/easy-rsa/keys/ca.crt
- /etc/openvpn/easy-rsa/keys/<client hostname>.crt
- /etc/openvpn/sample/client.conf (Rename to client.ovpn)
- service openvpn start
- Query service ps -aux | grep openvpn or ps –wwwaux
- Make the service be started with init.d scripts by editing /etc/default/openvpn AUTOSTART="all"