This is intended to be a very basic guide to getting a VPS up and going, it's aimed at the hobbiest who has enough linux knowledge to want to use a VPS but isn't quite sure how to go about getting it up and going. It assumes you'll be using an Ubuntu VPS from bitfolk, if this isn't the case then some of the things in this guide may be slightly off.
The sudo command is used a lot, this allows a 'normal' user to execute a command as root. When you use sudo you'll be prompted for your password the first time (and every so often afterwards), your password should be provided in the email sent when your VPS is configured.
Commands which need to be typed into a terminal (or better still copy-pasted) appear in underlined italics.
\Before we order our VPS we're going to setup a public/private key pair to use for logging into it. IF you already have a pair (eg for another VPS) then skip this step.
You need to download putty and puttygen from putty.org if you haven't already. Generating your private and public keys is easy simply open puttygen, change the key length to 2048 (using the text box at the bottom of the window) and click generate.
Once you've made them you need to save both the private and public key, make sure the private key is saved to a secure place - you MUST protect it. Make sure you use a passphrase.
Next we need to use putty to connect to our VPS, open putty and enter the address you were given to connect to but before clicking open you need to:
Use the command ssh-keygen -t rsa -b 2048 to generate your keys. Use the default options. You should use a pass-phrase, you'll be prompted for this whenever the private key is used. You should provide the contents of ~/.ssh/id_rsa.pub as your public key when you provision your vps.
Provisioning the VPS is a simple matter of visiting www.bitfolk.com/plans.html and following the instructions, make sure:
As soon as you can after getting the email from Andy to confirm that your VPS is up you need to login and start securing it. This is an important part as it protects you from having your VPS abused (and therefore incurring excess bandwidth charges and the wrath of Andy).
An important first step is to change your password, use the command passwd for this. Make sure that you choose a string password (8 or more characters, containing lower case, upper case and numbers) or visit https://www.grc.com/passwords.htm and use at least the first 8 characters from the '63 random printable ASCI characters' box.
The firewall is a bit of software which will control the internet traffic allowed into and out of your VPS. We'll be using iptables as it's powerful yet easy to setup, once you've learnt the options you need. IPTables works on the concept of chains, every packet it looks at starts life in a chain (in our case) either INPUT (for incoming data) or OUTPUT (for outgoing data). Rules are applied to these chains in order to tell the firewall what to do with these packets, if no rules match then the policy of the chain gets applied to the packet.
The first step is to install iptables so run sudo apt-get install iptables
We'll make sure any incoming stuff which relates to an established connection is allowed: sudo iptables --append INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
We need to make sure we allow inbound ssh: sudo iptables --append INPUT -p tcp --dport ssh -j ACCEPT
Lastly we make sure that any other incoming data is ignored: sudo iptables --policy INPUT DROP
Some people find it useful to be able use ping to check if internet machines are still there, the following command will add the reules needed to allow incoming ping requests and ping replies: sudo iptables --append INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT; sudo
iptables --append INPUT -p icmp -m icmp --icmp-type 0 -j ACCEPT
We'll also want to drop all ip6 packets (unless we're going to be using it). ip6tables works the same as iptables except it deals with IPv6 not IPv4. So sudo ip6tables --policy INPUT DROP and that's done.
One problem with iptables is that it clears the rules for an interface whenever it gets taken down, so we'll set things up so that when the interface goes down we save the rules we have and we'll reload them when the interface is started:
There are several things which we can do to strengthen the SSH service on our VPS, we're just going to worry about a few of the main ones, you'll need to edit the file /etc/ssh/sshd_config (use the command sudo nano -w /etc/ssh/sshd_config):
One of the most common attacks against a machine on the internet is trying to gain access using several different passwords (a dictionary attack). We'll be installing a software package which will block IP addresses (for a few minutes) in order to stop these attacks. Simply run: sudo apt-get install fail2ban
One of the most important things about staying secure is to make sure that the software on your VPS is kept upto date. New bugs are found, exploited and fixed all the time, by staying upto date you significantly reduce your chances of being cracked as a result of one of these bugs.
Firstly get a list of available updates: sudo aptitude update
Secondly apply the updates: sudo aptitude safe-upgrade upgrade
It can be a pain to manually check for updates frequently enough so we'll setup the VPS to nag us when updates are available, we'll be using a package called apticron for this:
Skip this section if you're sure you either don't want backups or that you'll take care of them yourself.
The backup machine logs in as root over ssh and uses rsync to backup the chosen files, so we need to:
Now you're ready to install and configure the services which you purchased your VPS to run. Remember to add firewall rules to allow the incoming connections which they require.
| Attachment | Size |
|---|---|
| validate-rync.txt | 344 bytes |
Recent comments
2 years 9 weeks ago