You can easily follow this steps to have your own VPN on your server.
1 . Install docker in your server
sudo apt install docker.io
2 . Make a directory with this command
mkdir /opt/openvpn
cd /opt/openvpn
3 . Pick a name for the $OVPN_DATA
data volume container
OVPN_DATA="ovpn-data"
4 . Initialize the $OVPN_DATA
container that will hold the configuration files and certificates. (replace VPN.SERVERNAME.COM
with your server IP)
docker volume create --name $OVPN_DATA
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://VPN.SERVERNAME.COM
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
5 . Start OpenVPN server process
docker run -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
6 . Take a rest, drink water, walk :))
7 . Generate a client certificate without a passphrase (replace CLIENTNAME with what you want!)
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full CLIENTNAME nopass
8 . Retrieve the client configuration with embedded certificates
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient CLIENTNAME > CLIENTNAME.ovpn
You can also use a trick for making ovpn
Make a bash file, name it script.sh
and wirte these in it
OVPN_DATA="ovpn-data"
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full $CLIENTNAME nopass
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient $CLIENTNAME > $CLIENTNAME.ovpn
Now if you want to make ovpn for 10 people you can run this command
for i in {1..10}; do export CLIENTNAME=user$i && sh script.sh ; done
9 . Now you can find your .ovpn file in /opt/openvpn
10 . (Optional) Just copy files to your machine ,go to your local machine and run this command
scp root@<your-server-ip>:/opt/openvpn/*.ovpn /home/azibom
If you have any questions, you can ask here:)
Share with your friends if you like
Top comments (0)