1
0
mirror of https://github.com/Nyr/openvpn-install.git synced 2024-12-01 01:16:05 +03:00

add server IP address to conf and key files to prevent

duplication file names with other VPNs
This commit is contained in:
Hoang Huynh 2014-02-27 18:11:38 +07:00
parent c430b7181b
commit c3189eacb4

View File

@ -39,7 +39,7 @@ if [ -e /etc/openvpn/server.conf ]; then
echo "3) Remove OpenVPN" echo "3) Remove OpenVPN"
echo "4) Exit" echo "4) Exit"
echo "" echo ""
read -p "Select an option [1-4]:" option read -p "Select an option [1-4]: " option
case $option in case $option in
1) 1)
echo "" echo ""
@ -54,14 +54,16 @@ if [ -e /etc/openvpn/server.conf ]; then
"$EASY_RSA/pkitool" $CLIENT "$EASY_RSA/pkitool" $CLIENT
# Let's generate the client config # Let's generate the client config
mkdir ~/ovpn-$CLIENT mkdir ~/ovpn-$CLIENT
cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf ~/ovpn-$CLIENT/$CLIENT.conf cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf ~/ovpn-$CLIENT/$CLIENT@$IP.conf
cp /etc/openvpn/easy-rsa/2.0/keys/ca.crt ~/ovpn-$CLIENT cp /etc/openvpn/easy-rsa/2.0/keys/ca.crt ~/ovpn-$CLIENT/ca@$IP.crt
cp /etc/openvpn/easy-rsa/2.0/keys/$CLIENT.crt ~/ovpn-$CLIENT cp /etc/openvpn/easy-rsa/2.0/keys/$CLIENT.crt ~/ovpn-$CLIENT/$CLIENT@$IP.crt
cp /etc/openvpn/easy-rsa/2.0/keys/$CLIENT.key ~/ovpn-$CLIENT cp /etc/openvpn/easy-rsa/2.0/keys/$CLIENT.key ~/ovpn-$CLIENT/$CLIENT@$IP.key
cd ~/ovpn-$CLIENT cd ~/ovpn-$CLIENT
sed -i "s|cert client.crt|cert $CLIENT.crt|" $CLIENT.conf sed -i "s|cert client.crt|cert $CLIENT@$IP.crt|" $CLIENT@$IP.conf
sed -i "s|key client.key|key $CLIENT.key|" $CLIENT.conf sed -i "s|key client.key|key $CLIENT@$IP.key|" $CLIENT@$IP.conf
tar -czf ../ovpn-$CLIENT.tar.gz $CLIENT.conf ca.crt $CLIENT.crt $CLIENT.key # this is the conf file for client's openvpn gui tool
cp $CLIENT@$IP.conf $CLIENT@$IP.ovpn
tar -czf ../ovpn-$CLIENT.tar.gz $CLIENT@$IP.conf $CLIENT@$IP.ovpn ca@$IP.crt $CLIENT@$IP.crt $CLIENT@$IP.key
cd ~/ cd ~/
rm -rf ovpn-$CLIENT rm -rf ovpn-$CLIENT
echo "" echo ""
@ -116,7 +118,7 @@ else
echo "" echo ""
echo "Do you want OpenVPN to be available at port 53 too?" echo "Do you want OpenVPN to be available at port 53 too?"
echo "This can be useful to connect under restrictive networks" echo "This can be useful to connect under restrictive networks"
read -p "Listen at port 53 [y/n]:" -e -i n ALTPORT read -p "Listen at port 53 [y/n]: " -e -i n ALTPORT
echo "" echo ""
echo "Finally, tell me your name for the client cert" echo "Finally, tell me your name for the client cert"
echo "Please, use one word only, no special characters" echo "Please, use one word only, no special characters"