= How to Make a Virtual Private Server (VPS) in 5 Steps =
Making the jump from shared hosting to a Virtual Private Server (VPS) is a relatively easy move. However, learning how to set up a VPS can be a bit trickier, especially if youâÃÂÃÂve never used the command line before
Download Complete Linux Commands Cheat Sheet
In this article, weâÃÂÃÂre going to walk you through
**how to set up a VPS** in five steps: Learning how to log into your VPS via Secure Shell (SSH) access. Updating your server. Creating a new user and modifying its privileges. Enabling public key authentication. Setting up a firewall for your VPS
Before we get into the technical details, though, weâÃÂÃÂre going to explain why youâÃÂÃÂll need to configure your new virtual server. LetâÃÂÃÂs talk about how to set up a VPS!
== Why You Should Configure Your New VPS ==
Usually, when you sign up for a basic hosting plan, your provider will set up all the software youâÃÂÃÂll need to use it. With shared hosting, for example, youâÃÂÃÂll probably get access to a control panel for your account right away:
These hosting control panels provide you with all the options you need to configure your account. However, in most cases, you wonâÃÂÃÂt get the chance to tweak your serverâÃÂÃÂs actual settings, because other people are also using the same machine
With a VPS, on the other hand, you get a server environment all to yourself. In most cases, your host will only go so far as to set up basic server software âÃÂàsuch as Apache or Nginx âÃÂàand the rest is up to you. Additionally, you might want to install a control panel like Cyberpanel for easier management. That means youâÃÂÃÂll probably need to go through a few extra steps to get your server âÃÂÃÂreadyâÃÂÃÂ, such as:
- Deciding when should you start using VPS
- Learning how to connect to it and issue commands
- Figuring out how to install new software and perform updates
- Configuring new user accounts (if needed)
- Setting up a firewall
When we talk about issuing commands to your server, weâÃÂÃÂre referring to something like this:
Usually, youâÃÂÃÂll interact with your VPS using the command line instead of a Graphical User Interface (GUI). That can be intimidating at first, but youâÃÂÃÂll quickly get used to it if you donâÃÂÃÂt mind Googling around for the right commands and following some simple tutorials
You
*can *also set up hosting control panels that will enable you to interact with your server using a GUI. However, weâÃÂÃÂre not going to cover that in this article, since using the command line is often the more efficient route. Plus, learning how to use simple commands will teach you a lot about server management, which will almost certainly come in handy as your site grows
== 5 Steps to Configure Your New VPS and Get It Ready to Use ==
As you may know, the vast majority of web servers run on Unix-based systems. That means youâÃÂÃÂll need to use commands tailored to that type of Operating System (OS), which are not the same as those youâÃÂÃÂd use on a Windows machine. If you want to learn more about Windows server management, check out this guide for more details
With that out of the way, letâÃÂÃÂs talk about how to set up a VPS!
Step 1: Learn How to Log into Your VPS via Secure Shell (SSH) Access
There are several ways you can connect to a website, beyond using a browser. For example, you can use File Transfer Protocol (FTP), which enables you to upload, download, and edit files on your server:
While FTP can be very useful, the protocol doesnâÃÂÃÂt enable you to issue commands to your server. For that, youâÃÂÃÂll need to use Secure Shell (SSH) access, which is a different type of protocol that provides you with access to remote servers
Once you connect to a server via SSH, youâÃÂÃÂll be able to issue commands to it. SSH is also renown for its strong encryption and authentication protocols, which make it highly secure. By learning how to use SSH, youâÃÂÃÂll be taking your first steps into server management
Once you sign up for a VPS plan, your web host should provide you with a set of credentials, including:
- Your serverâÃÂÃÂs IP address
- A username (usually
root)
- A password for your
root
In case youâÃÂÃÂre not familiar with the term, a
**root or **superuser account is a user with full privileges and access on a specific system. You can think of it as the equivalent of an administrator, but with even more power
When you set up a VPS, youâÃÂÃÂll start off with a single
**root** account, which is the one youâÃÂÃÂll use to make the initial connection. If youâÃÂÃÂre using a Unix-based OS on your end, you can connect to your server directly from the command line
However, if youâÃÂÃÂre using Windows, youâÃÂÃÂll first need to install an SSH client. WeâÃÂÃÂre partial to two clients in particular, the first of which is called Bitvise:
If youâÃÂÃÂre looking for a simple interface that resembles the classic Windows style, you canâÃÂÃÂt go wrong with Bitvise. However, youâÃÂÃÂll be doing most of your work within the command line, so the style doesnâÃÂÃÂt matter much
WeâÃÂÃÂre also big fans of PuTTY, which features a far more minimal interface. However, it offers a lot of additional configuration options, making it preferable if you really want to dip your toes into server management
For the rest of this tutorial, weâÃÂÃÂre going to be using PuTTY in our examples. With that in mind, go ahead and install the program, and then execute it. YouâÃÂÃÂll see a window like this one:
At this stage, you need to enter your serverâÃÂÃÂs IP address into the
**Host Name (or IP address) **field, and leave the **Port **setting to the default value of **22
Pro Tip
Aside from SSH connections, port 22 is also used for secure logins and Secure File Transfer Protocol (SFTP). You can also change the SSH port if you like
You may notice that thereâÃÂÃÂs an option to select which connection type you want to use below the IP field. Choose
**SSH, **and then you can go ahead and hit the **Open **button
A command line window will open now, and youâÃÂÃÂll see a prompt to enter your login information. In this case, that will be
**root **and its corresponding password:
If the data entered is correct, youâÃÂÃÂll see a brief summary of your serverâÃÂÃÂs details, and a prompt to enter more commands:
ThatâÃÂÃÂs it for the first step of how to set up a VPS. DonâÃÂÃÂt close the command line window yet, however, since we still have work to do
Step 2: Update Your Server
Once you log into your VPS, youâÃÂÃÂll see a message that tells you if there are any âÃÂÃÂpackagesâÃÂàor security updates available:
Packages are essentially software in Unix-speak. When it comes to any system, itâÃÂÃÂs always important to keep its components up to date, and servers are no exception
If youâÃÂÃÂre using outdated software, you open up your server (and website) to security vulnerabilities. Plus, you might be missing out on new features or improved performance. ThatâÃÂÃÂs why the first thing youâÃÂÃÂll want to do is update your serverâÃÂÃÂs packages, and download any pending security patches
To get started, type in the
**apt update **command and hit **Enter Now, your server will double-check what packages need upgrading. Once itâÃÂÃÂs done, enter **apt upgrade which will update your serverâÃÂÃÂs packages:
This process might take a while, depending on how many updates your server needs to install. So sit back, grab some coffee, and wait for it to be done
Once all your packages are up to date, you should go ahead and restart your server using the
**reboot **command. Then, close the command line window. Wait a minute or two, and log back in using PuTTY (or your client of choice)
If everything went according to plan, there shouldnâÃÂÃÂt be any more available updates listed. That means we can move on to the next step of learning how to set up a VPS
Step 3: Create a New User and Modify Its Privileges
When you set up a VPS, you start off with a
**root **user, which is the account youâÃÂÃÂve been using so far. However, itâÃÂÃÂs usually a good idea to set up another user account with superuser privileges
The reason for this is that the
**root **account can cause some severe damage if youâÃÂÃÂre not sure what youâÃÂÃÂre doing. A **root **account has full access to all of your systemâÃÂÃÂs settings, so one wrong command can create serious problems
A regular user account with superuser privileges, on the other hand, needs to add the
**sudo **prefix to any command it wishes to run using administrative privileges. This may seem like a small change, but it makes a huge difference. With this approach, youâÃÂÃÂll need to think twice before running any command using the **sudo **prefix, which can help you avoid mishaps
Go ahead and set up that new user now by entering the following command. YouâÃÂÃÂll want to replace the second part with whatever username youâÃÂÃÂd like to use:
**adduser yournewusername**
Then, type in this line to add that user to the
**sudo **group, which will give it superuser privileges (again, replacing the placeholder with your new username):usermod -aG sudo yournewusername**
Now, all thatâÃÂÃÂs left is to set up a password for this account. However, thereâÃÂÃÂs a method thatâÃÂÃÂs far more secure than using a normal password, which is what weâÃÂÃÂll look at next
Step 4: Enable Public Key Authentication
Public key authentication is a technique thatâÃÂÃÂs arguably more secure than regular passwords. With this approach, you generate a set of both âÃÂÃÂpublicâÃÂàand âÃÂÃÂprivateâÃÂàkeys
Your server will store your public key and use it to authenticate the private one, which only you will have access to as a file on your computer. Once you set up public key authentication, youâÃÂÃÂll need both the private key and a passphrase to log in, which increases security significantly
To generate SSH keys in Windows, you can use the PuTTYgen app, which will have been installed when you set up the client earlier (for details about how to do this on Linux/Unix systems, check out this guide). Look among your programs for it and run the PuTTYgen app now, which should look like this:
ItâÃÂÃÂs fine to use the default settings for your key pair, so go ahead and click on the
**Generate **button now. To make your key more unique, the program will ask you to move your mouse around to randomize it, which is pretty cool:
Next, the program will show you the public key it generated for you. Before you do anything else, go ahead and set up an accompanying passphrase for it, which will act as a password alongside the key:
Now, go ahead and hit the
**Save private key **button, and save the resulting file to your computer. YouâÃÂÃÂll also need to copy your public key in a moment, so donâÃÂÃÂt close this window just yet
Then, log back into your server using the original
**root **user, and move to your new accountâÃÂÃÂs home directory usingsu âÃÂàyournewusername The command line will now reflect your new user:
After that, youâÃÂÃÂll need to run a series of commands in order, which will create a new folder for your public key, restrict that folderâÃÂÃÂs permissions, and save your key:
mkdir ssh chmod 700 ssh nano ssh/authorized_keys
That last command will open up the Nano editor, enabling you to modify the new
**authorized_keys **file on your server. Go ahead and copy your public key now from the PuTTYgen window, and paste it in here
Once the key is ready, hit
**CTRL + X **to close the editor, and enter **Y **when it asks you to confirm the changes to the file. Then, type in the following two commands:
chmod 600 ssh/authorized_keys exit
Those will change the permissions for the file you just edited, and then return you to the
**root **user
Next, youâÃÂÃÂll need to configure PuTTY to use your private key when you connect to your server so that it can recognize you. To do this, return to the appâÃÂÃÂs main screen and go to the
**Connection âÃÂú SSH âÃÂú Auth **section. Inside, youâÃÂÃÂll find a field called **Private key file for authentication
Click on the
**Browse **button, and then locate the private key file you stored on your computer. Select it, and youâÃÂÃÂre good to go
Finally, you need to tell your server to disable the default password-only authentication method for the new user you just set up. To do that, log into your server as the new user via SSH, and run this command:
sudo nano /etc/ssh/sshd_config
This will open the
**sshd_config **file using the Nano editor. Look for the line that reads **PasswordAuthentication **inside that file, and delete thesign before it. Then change its value from **Yes **to **No so it reads like this:
PasswordAuthentication no
Save the changes to the file, and reboot your server. The next time you attempt to log in, youâÃÂÃÂll only be able to do so using your private key and passphrase
Step 5: Set Up a Firewall for Your VPS
WeâÃÂÃÂve covered a lot of ground so far about how to set up a VPS. However, thereâÃÂÃÂs still one final step to perform if you want to keep your server secure. That is to enable a firewall for it
You can do this using the iptables program, which enables you to set up rules that restrict traffic to and from your server. This process is a bit involved, though, so we recommend that you check out our full guide on how to set up iptables and configure the program properly
This step may seem like overkill at first. With Iptables, however, youâÃÂÃÂll be able to restrict which ports enable traffic to access your server. This will stop a lot of attacks in their tracks. Plus, itâÃÂÃÂs a one-time setup process, so it pays to do it right away
Ready to Move On?
Learn how to connect your domain name with your new plan âÃÂàHow to Point a Domain to VPS?
Step-by-step guide to migrating from managed hosting âÃÂàHow to Migrate a Website from Shared Hosting to VPS?
How to Change Hostname on Linux Servers
How to Install and Use Tmux for Task Handling
How to Install FFmpeg on Linux
How to Install and Use Linux Screen
== Conclusion ==
Learning how to set up a VPS after upgrading from shared hosting is like leaving the kiddie pool to dive into an Olympic-sized one. You have a lot more room and features to play with, but youâÃÂÃÂll need to find your footing before you can start having fun. Now that you know how to configure your VPS, youâÃÂÃÂve become acquainted with the command line, which will make it a lot easier to set everything up to your liking
Do you have any questions about how to set up a VPS? LetâÃÂÃÂs talk about them in the comments section below!