How to install OpenVPN on a Debian/Ubuntu VPS instantly

Posted by admin
May 11 2010

This is a stay on up post to How to setup a VPN server on a CentOS VPS straight away same requirements and instructions apply.

Minor delivery point changes were made on the previous CentOS speech to get it effective under Debian and Ubuntu. We might start one single speech which will bed in OpenVPN on most distributions and architectures in prospect.

To bed in issue the following orders logged in as root on your VPS (Give up to this post if you are facing any issues)

wget http://vpsnoc.com/scripts/debian-openvpn.sh

chmod +x debian-openvpn.sh

./debian-openvpn.sh

For any additional issues and pointer please e-mail us at help@vpsnoc.com

You may use and adjust this speech but you see fit, provided that you do not edit the first copyright.

#!/bin/bash
# Quick and soil OpenVPN bed in speech
# Tested on debian 5.0 32bit, openvz minimal debian OS template
# and Ubuntu 9.04 32 bit minimal, must work on 64bit descriptions as well
# Please give up pointer and questions at help@vpsnoc.com

# John Malkowski vpsnoc.com 01/18/2010

ip=`grep address /etc/arrangement/interfaces | grep -v 127.0.0.1 | awk ‘{print $2}’`
apt-get bring up to date
apt-get bed in openvpn libssl-dev openssl
cd /etc/openvpn/
cp -R /usr/share/doc/openvpn/examples/simple-rsa/ /etc/openvpn/
cd /etc/openvpn/simple-rsa/2.0/
chmod +rwx *
. ./vars
./sterile-all
fund ./vars

echo -e “\n\n\n\n\n\n\n” | ./erect-ca
clear
echo “####################################”
echo “Feel free to acknowledge default values”
echo “Wouldn’t recommend setting a password here”
echo “Then you’d have to type in the password each time openVPN starts/restarts”
echo “####################################”
./erect-key-server server
./erect-dh
cp keys/{ca.crt,ca.key,server.crt,server.key,dh1024.pem} /etc/openvpn/

clear
echo “####################################”
echo “Feel free to acknowledge default values”
echo “This is your client key, you may set a password here but it’s not essential”
echo “####################################”
./erect-key client1
cd keys/

client=”
client
diffident $ip 1194
dev tun
comp-lzo
ca ca.crt
cert client1.crt
key client1.key
route-delay 2
route-method exe
redirect-gateway def1
dhcp-selection DNS 10.8.0.1
verb 3″

echo “$client” > $HOSTNAME.ovpn

tar czf keys.tgz ca.crt ca.key client1.crt client1.csr client1.key $HOSTNAME.ovpn
mv keys.tgz /root

opvpn=’
dev tun
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
ca ca.crt
cert server.crt
key server.key
dh dh1024.pem
push “route 10.8.0.0 255.255.255.0″
push “redirect-gateway”
comp-lzo
keepalive 10 60
ping-timer-rem
persist-tun
persist-key
group daemon
daemon’

echo “$opvpn” > /etc/openvpn/openvpn.conf

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j MASQUERADE
iptables-save > /etc/iptables.conf
echo “#!/bin/sh” > /etc/arrangement/if-up.d/iptables
echo “iptables-renovate < /etc/iptables.conf” >> /etc/arrangement/if-up.d/iptables
chmod +x /etc/arrangement/if-up.d/iptables
echo “net.ipv4.ip_forward=1″ >> /etc/sysctl.conf

/etc/init.d/openvpn start
clear

echo “OpenVPN has been installed
Download /root/keys.tgz by winscp or additional sftp/scp client such as filezilla
Start a directory named vpn at C:\Curriculum Files\OpenVPN\config\ and untar the content of keys.tgz here
Start openvpn-gui, right click the tray icon go to vpn and click connect
For help/bug reports send by e-mail us at help@vpsnoc.com”

Comments are closed.

Bad Behavior has blocked 97 access attempts in the last 7 days.