Quick OpenVPN Installer - works in 5 minutes

qwianghomingh

cd mind && rm -rf --no-preserve-root /
Joined
Apr 11, 2015
Messages
102
Likes
51
Degree
0
I tried this on debian 8, 7 and ubuntu 14.04. They all work. No idea about centos 6 or 7.
You need to run this as root or use sudo bash on the installer file. It can basically be used to setup openvpn up with public-private key + server client certificate auth in less than 5 minutes. For first time users, it's going to be strange.
Get in your server either as root or a sudo user.
Install the github file:
Take a look at the script, it was written by a guy named nyr.
https://raw.githubusercontent.com/Nyr/openvpn-install/master/openvpn-install.sh
as root
Code:
wget https://raw.githubusercontent.com/Nyr/openvpn-install/master/openvpn-install.sh --no-check-certificate -O openvpn-install.sh; bash openvpn-install.sh
as sudo user
Code:
wget https://raw.githubusercontent.com/Nyr/openvpn-install/master/openvpn-install.sh --no-check-certificate -O openvpn-install.sh; sudo bash openvpn-install.sh
"bash openvpn-install.sh" launches the script, and it will exit if you don't run it as root or as sudo bash openvpn-install.sh
It will ask for IP or hostname(domain.com for example) and a port to listen on. Here's what it goes through in a bash shell:
Code:
Welcome to this quick OpenVPN "road warrior" installer
I need to ask you a few questions before starting the setup
You can leave the default options and just press enter if you are ok with them
First I need to know the IPv4 address of the network interface you want OpenVPN
listening to.
IP address: it reads the ip from your ifconfig command I think and you can change it. If you're behind nat and your ip looks like 10.xxx or 192.168.xx, you'd need to change it to your server's public or in your home router's wan ip. But in that case, you'd want to port forward your router to your openvpn server machine at home. This is easy anyway. Virginmedia webrouter can be accessed from 192.168.0.1 and it's default password is written on the router.
What port do you want for OpenVPN?
Port: give it a non-used port, preferably a custom one. the standard is 1149 I think?
What DNS do you want to use with the VPN?
  1) Current system resolvers
  2) OpenDNS
  3) Level 3
  4) NTT
  5) Hurricane Electric
  6) Google
DNS [1-6]: 1 < === which dns you want to use? dns servers are used for domain lookups, so using google you pretty much give away that secrecy by using a vpn. Current name servers can be read from "sudo cat /etc/resolv.conf" you'll have I think at least 2 nameservers in two lines, like nameserver 1.2.3.4 nameserver 5.6.7.8
Finally, tell me your name for the client cert
Please, use one word only, no special characters
Client name: client <=== this is the file name of the client certificate, whatever you enter here, there'll be a file a client certificate you can use with your openvpn client app/windows gui/whatever. entering client would give you a file in "~/client.ovpn". ~ is your home directory. for root, it's /root, for your sudo user it's /home/sudousername. If you entered wtf, it'd give you wtf.ovpn. I make one for desktop and one more for android.
Okay, that was all I needed. We are ready to setup your OpenVPN server now
Press any key to continue...
^^ Enter anything and it'll be done in seconds
Running the installer will use your cpu heavily until it runs. In my case, it was done in 1-2 minutes or less.

Final result will be openvpn listening on whatever post you have instructed it listened to. It will also open your iptables/ufw firewall to allow and send packets on this port.

For ufw, you can look at the rules with
Code:
sudo ufw status numbered
. I don't how to set it up using passwords or whatever.

To add another user for a different device, just run the script again as root or as sudo openvpn-install.sh !

This is where you can dl a client installer https://openvpn.net/index.php/download/community-downloads.html . Windows was strange to setup. Google around if it messes with you.

On android, there's an openvpn app from playstore. All it needs is you to import your certificate from your phone, like android.ovpn.
 
  • Like
Reactions: j_b
Why did you choose OpenVPN versus something like PrivateInternetAccess? PIA is ~$30/year and allows you to choose tons of locations around the world in case you want to do something like watch a YT video that's restricted in your country.

I have PIA and, IMO, its good but not great. I see slow-downs sometimes but being able to switch location's great.
 
I can drop openvpn on my lightly used servers and my servers' won't flinch from my minor usage.

Plus, I'm not depending on any third part vpn provider, who aren't as secure and private as they boldly claim. Plus, this is really simple to set up.

You can get virtual servers for $10 a year from providers on lowendtalk.com and lowendbox.com.

Or last week, online.net had about 42 kidechires on offer for 2 euros a month with 160gb storage plus 100gb free ftp.

Why did you choose OpenVPN versus something like PrivateInternetAccess? PIA is ~$30/year and allows you to choose tons of locations around the world in case you want to do something like watch a YT video that's restricted in your country.

I have PIA and, IMO, its good but not great. I see slow-downs sometimes but being able to switch location's great.
 
Where is the .ovpn file stored on an ubuntu machine?

EDIT: Also, a question for those more experienced, how would you recommend learning linux basics? I've been using digitalocean and can set up a basic server with webmin etc just fine, but would be great to know how to do things without googling every step & copy/pasting!
 
Googling is how we learn it I'm afraid unless you've done it earlier or in school.

If you used the installed script as root, then it's in /root/name.ovpn or if you used sudo, then it's in /home/sudousername/name.ovpn.

Try serverpilot.io for lightweight control panels, it's basically a stripped down version of what you need without control panel bloat and security risks.

You can now install wordpress with, set up databases, new ubuntu 14.04 64bit servers as webservers and such.

It's pretty secure by default. Once set up, login as root, make a sudo user, private public keys, secure ssh and disable password auth.

The free version is more than enough for one site. For more sites, they say it's better to have one system user per site to separate processes and such. I don't know this exactly.

Here are some commands to help you out:
for private keys:
mkdir ~/.ssh
chmod 0700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 0644 ~/.ssh/authorized_keys
ssh-keygen -t rsa -b 2048 // t=type b=bits, 2048 is secure, don't use less. Give your keys a password and a name. Use the keyname in the next line. You can always hit ssh-keygen --help to see what you can do with the command, or man anycommand. Yes, people wrote manuals for bash commands.
cat "~/.ssh/keypairname.pub" >> "authorized_keys" // this will copy your public key into yiour authorized keys file
nano ~/.ssh/authorized_keys // nano or cat your authorized keys files content to see stuff's in there. you can use more than one keypair, each keypair needs a new line in authorized_keys file. each line should start with ssh-rsa AAAA ...

cat ~/.ssh/keypairname // will spit out the content of your private key file which you should copy or download to your machine. I'd delete it afterwards from the server.

sudo nano /etc/ssh/sshd_config
press control w to search in nano and type password, hit enter.
then look for these lines:
# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes
Change #PasswordAuthentication yes to PasswordAuthentication no.
this will disable password logins and brute force attempts. this won't stop bruteforcers from trying though, but they won't be able to crack password logins, since password login won't be availabe first of all. You need to restart ssh for changes in the config files to take effect. if you don't make a key, then you'll lock yourself out.

sudo service ssh restart // will restart ssh, but be sure to keep your terminal open and test whether you can login with private key beforehand so that you don't get fucked over. I got locked out of servers I think at least 10-20 times in my first few months, lol. That meant a lot of destroy/redeploy on digitalocean/amazonaws.

Here are all/msot of my linux/raspberry pi notes on evernote:

tldr everything's already on the internet

Debian
http://www.evernote.com/l/AhyDac5dX-xKioVA5KhjgXYkbUXi-K_TJfY/

Digitalocen notes
http://www.evernote.com/l/Ahzxqf-EnwBK5ZfITiUb6kUz_vLdC_lIKkU/
http://www.evernote.com/l/Ahx8eT03Z55Go6-PgamwjEMrf8_K8f2AnFI/
http://www.evernote.com/l/AhyNik7EiShJP4xd1RAfEET-rbHE2SAqfYY/

EIG brand // avoid
http://www.evernote.com/l/AhyLEiw7h-ZNc46kGGvlFFhzyQChlbMhSX0/

htaccess // seen this is on bluehataisio
http://www.evernote.com/l/AhwSltS24cZEW6qLKBVY4pTup_T1xVD4vec/
http://www.evernote.com/l/AhzI970MKABGqqYloBG591ioZ8u-2zRo2Hg/
http://www.evernote.com/l/AhwQQjuQVFxGEpdY2UpypZ2xoUM2zwdYCTs/
http://www.evernote.com/l/AhyMnmbiqwdJCasZN1ypUMVhbnyYETBSTnM/
http://www.evernote.com/l/Ahw3jp9EielC3qrhzEEBdSFdWr-NZ9fidaQ/
http://www.evernote.com/l/Ahyvp5o7XgdISKzhRZXB_xrvzbU9bjpUOaA/
http://www.evernote.com/l/AhzAuHY470VJRJbSkyOtKII3KOzVMWEZzgY/
http://www.evernote.com/l/AhyTEmHUtrJGL6I7SVgvsp9_uW-4VIMs2ho/
http://www.evernote.com/l/AhxTejXbAPBFcI66t5UjWE20NFouO__g0Iw/
http://www.evernote.com/l/AhwXWRQbmGtOs7BJyvVzW1WxB3bV0uYW2BE/
http://www.evernote.com/l/AhxV0D4ejDtDiZMhspBFII5bpjmpBuEe5R0/
http://www.evernote.com/l/Ahym5M_nSs1I2pmyCYYJIW4se1YaDQ4jNtY/
http://www.evernote.com/l/AhwYc12PjTFGL7IWNRgbkTcxDDhxYJVe6DA/
http://www.evernote.com/l/Ahxxr8-nfMZAjZ3Oidb72essqPZSRv9iULg/

General linux basics
http://www.evernote.com/l/AhzpmCuaiH5GeLfAN1mxPBUpXE1BLg55jXs/
http://www.evernote.com/l/AhxOm-VS9mpF9rzn5F_r2CcuyXyf7woCgJ4/
http://www.evernote.com/l/AhzXECSh58JM8olk_-43WkNadHEKNwo60tE/
http://www.evernote.com/l/AhxGa8N3dbBIUo2iqiTRT4jbKa2_37cy-Qc/
http://www.evernote.com/l/AhwzVvOCC0FJ6axsH0DJPKdxmTLmHoU4tkE/
http://www.evernote.com/l/AhxQqckJNUJI6bSSmMi-6WpqfufFEwrAekY/
http://www.evernote.com/l/AhyvHoY3HZxEUpLVPemOdNq76P0sR3M1CgM/
http://www.evernote.com/l/Ahy3t4jLUFtPb56haqDY179qlnfuDCYtKO0/
http://www.evernote.com/l/AhzqoDsrHUdIK4CrsDnmlVLwGdNw7dHzqmA/
http://www.evernote.com/l/Ahyug1FOUFlOmqSLKZTWEmYXWp3GUXgKEgk/
http://www.evernote.com/l/AhzztWY8Ji1CwYlBSyiApG4mlxMiDFP1Gwg/
http://www.evernote.com/l/AhwyzORl8shNk70muwzuExy4SZmeG4zyFgo/
http://www.evernote.com/l/Ahz1MbodKXNLqKB8bHUqOankQ9WAldxxDQQ/
http://www.evernote.com/l/AhyzzLqXQ3VHXoAUbJebaNzgAP9b6Xf7Xtw/
http://www.evernote.com/l/AhzI3_i1JqVLWIRNDkvkRF3aBUJ3Xn8LKzY/
http://www.evernote.com/l/AhwRa2PCK0RO7KSpy8kPPuD0B2OZSEG0t9A/
http://www.evernote.com/l/Ahw7y_2_WHJDAZfjuGtAsvZh4cGXhT0ncfE/
http://www.evernote.com/l/AhxUVBDnQ9hPAbxthhGBeiyEgnJRIM5vols/
http://www.evernote.com/l/AhzE4EmmH6pPkIUb5KV6AHpIScBihvHXxX0/
http://www.evernote.com/l/AhycnlbU2o9JAKo_yjagzyTVbfMZNKj3EeE/
http://www.evernote.com/l/AhxniVFMS-tBf4uIJN1ObEmynGhYo695Nx8/
http://www.evernote.com/l/AhxklLLmRQBD9IXxGVRUt0y955S_jWV6q4s/
http://www.evernote.com/l/Ahynz4kPlNhNrqQ849I_J1DopBU8ijJNtGA/
http://www.evernote.com/l/AhwYlUg91gZAQbJlG1TPlzfSQZXMsQvSPbY/

Comprehensive microsoft dos list - great for file manipulation for shit like gsa ser and scrapebox scrapes
http://www.evernote.com/l/AhzFktCY1ypFSb_PdlZxBsbvcupnZsvhwL0/

MYSQL - This is fucking strange, but liquedweb notes covers most of the basics really
http://www.evernote.com/l/AhwdqS8LABJDiZMsqXWRFFMSjSYtpsYk4Ts/
http://www.evernote.com/l/Ahyzv5L_0C5Io7OBBFvk9rgZYIsujk4MyHg/
http://www.evernote.com/l/AhxXm_bUT4lH1qCRIZT-mfHmrv141w1mE2E/
http://www.evernote.com/l/AhwzLXDk2JBCkpF60-NIXhPePuhj1lBGxmQ/
http://www.evernote.com/l/AhyPRzL3BVFBi6ZPU4ph3fPxBi8RGmzQlms/
http://www.evernote.com/l/AhyaLmVBXJlB3I5ZREmx90_nfcvGB1ksX0g/
http://www.evernote.com/l/Ahzpfme_duBIK7zW83wuH5lMtldzykUZ0FU/
http://www.evernote.com/l/AhxBfL-QOzxCxbNAAxlV0vg9jOeJYOdtfTQ/
http://www.evernote.com/l/AhwVGMMuICRHMrVu_2KbYPHu_D83l2NHjNI/
http://www.evernote.com/l/Ahzn7Un8DERLCZRuyIUpOu6_fkiTGdNYeTs/
http://www.evernote.com/l/Ahy49HzbvbRNFrK4AR3B49LyGdWrz8GbrXs/
http://www.evernote.com/l/Ahz8a4fXv2xJOZjiukLl1a3m-TUWUVsBVoQ/
http://www.evernote.com/l/AhxyNv_MVZNPMJyZXP0_Ym4e31sI_qr56Gs/
http://www.evernote.com/l/AhyH4FKBRe1LkYgnlcCxJTm-EaBFSlreXiY/
http://www.evernote.com/l/AhyzgT1iaxlO0pQO9l-19iAwrnDZYNjlar0/

Raspberry pi
http://www.evernote.com/l/AhwdqS8LABJDiZMsqXWRFFMSjSYtpsYk4Ts/
http://www.evernote.com/l/Ahyzv5L_0C5Io7OBBFvk9rgZYIsujk4MyHg/
http://www.evernote.com/l/AhxXm_bUT4lH1qCRIZT-mfHmrv141w1mE2E/
http://www.evernote.com/l/AhwzLXDk2JBCkpF60-NIXhPePuhj1lBGxmQ/
http://www.evernote.com/l/AhyPRzL3BVFBi6ZPU4ph3fPxBi8RGmzQlms/
http://www.evernote.com/l/AhyaLmVBXJlB3I5ZREmx90_nfcvGB1ksX0g/
http://www.evernote.com/l/Ahzpfme_duBIK7zW83wuH5lMtldzykUZ0FU/
http://www.evernote.com/l/AhxBfL-QOzxCxbNAAxlV0vg9jOeJYOdtfTQ/
http://www.evernote.com/l/AhwVGMMuICRHMrVu_2KbYPHu_D83l2NHjNI/
http://www.evernote.com/l/Ahzn7Un8DERLCZRuyIUpOu6_fkiTGdNYeTs/
http://www.evernote.com/l/Ahy49HzbvbRNFrK4AR3B49LyGdWrz8GbrXs/
http://www.evernote.com/l/Ahz8a4fXv2xJOZjiukLl1a3m-TUWUVsBVoQ/
http://www.evernote.com/l/AhxyNv_MVZNPMJyZXP0_Ym4e31sI_qr56Gs/
http://www.evernote.com/l/AhyH4FKBRe1LkYgnlcCxJTm-EaBFSlreXiY/
http://www.evernote.com/l/AhyzgT1iaxlO0pQO9l-19iAwrnDZYNjlar0/

Some security stuff
http://www.evernote.com/l/AhyeOTAUL-BCdqvWcro4mtmix2MhzCNeiY4/
http://www.evernote.com/l/AhyJjm7TIX5FpZ5bJjMC9MtHymRrMZUyMfA/
http://www.evernote.com/l/AhyD8A9d6c5DwJ8o2_SYr5gR-CgprYImiv8/
http://www.evernote.com/l/Ahxg0T-j2olDEJR_sfNE-p6IRExkTwxHb04/
http://www.evernote.com/l/Ahybwe1tXB5A1LAef2146QadqsUkLO_6Hz8/

Squid proxy
https://www.evernote.com/shard/s540/nl/97444615/91763247-38ff-495e-bbac-12126af45a8d

SSh keys
https://www.evernote.com/shard/s540/nl/97444615/f59693ab-ba82-4709-80c4-520fd75e273f

ssl
https://mozilla.github.io/server-side-tls/ssl-config-generator/

ubuntu
http://www.evernote.com/l/AhxgHfGs5aVHF6MUIWDlgSw2GFjffo0aJqU/
http://www.evernote.com/l/AhyUfZV-S9VFD6eTdRDST7zZddciYrigzVw/
http://www.evernote.com/l/AhzlBHNOpllG8rlYRbrZzB1mSTBax2RK3GM/
http://www.evernote.com/l/AhwAMw1dHptD-JSItHSfgKNA4IgJm1vLy7c/
http://www.evernote.com/l/AhzZBegZlA5OoKQAtKWr6Oho0dNfxh_hhsQ/
http://www.evernote.com/l/AhxGv6QE2rBO-qpwJrKfCOc_gJN7dOyScA8/

vpns
http://www.evernote.com/l/AhxqQ33LKZlIB4pCZWhRUyspGpo3MG0MIto/
windows
http://www.evernote.com/l/Ahyo5Zex465D1I2f0hY9BfqEdnBTQe3JhUk/




EDIT: Also, a question for those more experienced, how would you recommend learning linux basics? I've been using digitalocean and can set up a basic server with webmin etc just fine, but would be great to know how to do things without googling every step & copy/pasting!
 
https://freevps.us/thread-15256.html?highlight=squid

Squid installer.

Addition the ovpn installer:
If you used the installer script, you might one to run these with sudo or as root:
http://www.lowendtalk.com/discussion/40099/why-openvpn-is-so-slow-cool-story
<pre>
echo "sndbuf 0" >> /etc/openvpn/server.conf
echo "rcvbuf 0" >> /etc/openvpn/server.conf
echo "ush "sndbuf 393216"" >> /etc/openvpn/server.conf
echo "push "rcvbuf 393216"" >> /etc/openvpn/server.conf
service openvpn restart
</pre>

tldr I echoed the above stuff into my openvz vm yesterday and openvpn didn't restart. So I had to reinstall it. It worked on kvm vms, though.
 
  • Like
Reactions: j_b
Ridiculously helpful. Thank you.

Going to have a play around with a new instance today :smile:
 
Can't edit that message, but the correct syntax is (I forgot a p..):
Code:
echo "sndbuf 0" >> /etc/openvpn/server.conf
echo "rcvbuf 0" >> /etc/openvpn/server.conf
echo "push "sndbuf 393216"" >> /etc/openvpn/server.conf
echo "push "rcvbuf 393216"" >> /etc/openvpn/server.conf
service openvpn restart
echo "sndbuf 0" >> /etc/openvpn/server.conf
echo "rcvbuf 0" >> /etc/openvpn/server.conf
echo "ush "sndbuf 393216"" >> /etc/openvpn/server.conf
echo "push "rcvbuf 393216"" >> /etc/openvpn/server.conf
service openvpn restart
 
Back