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
5 Steps to Configure Your New VPS and Get It Ready to Use
- Step 1 Learn How to Log into Your VPS via Secure Shell (SSH) Access
- Step 2 Update Your Server
- Step 3 Create a New User and Modify Its Privileges
- Step 4 Enable Public Key Authentication
- Step 5 Set Up a Firewall for Your 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:
- DNS zone checkup using named-checkzone command
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:
uploading wordpress files via ftp
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 account
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 are using Windows, you will need to install the SSH client first. We sided with two customers in particular, the first of which is called Bitvise:
If you’re looking for a simple interface that looks like classic Windows style, you can’t go wrong with Bitvise. However, you’ll be doing most of your work in the command line, so style doesn’t really matter.
We’re also big fans of PuTTY, which features a much more minimal interface. However, it offers a lot of additional configuration options, which makes it preferable if you really want to dive into server management.
For the rest of this tutorial, we’ll be using PuTTY in our example. With that in mind, go ahead and install the program, then run it. You will see a window like this:
PuTTY SSH client.
At this point, you should enter your server’s IP address in the Hostname (or IP address) field and leave the Port setting at the default value of 22:
Configure PuTTY to connect to your server.
In addition to 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 wish.
You may notice that there is an option to select the type of connection you want to use under the IP field. Select SSH, then you can go ahead and hit the Open button.
Now a command line window will open and you will see a prompt to enter your login information. In this case, it would be root and the appropriate password:
Log in to your root account.
If the data entered is correct, you will see a brief summary of your server details and a request to enter more commands:
Your server details.
That’s all for the first step on how to set up a VPS. However, don’t close the command line window, as we still have some work to do.
Step 2: update your server
After logging into your VPS, you’ll see a message letting you know if there’s a “package” or security update available:
Check for available updates.
Packages are basically Unix language software. When it comes to any system, it is always important to keep its components up to date and servers are no exception.
If you use outdated software, you expose your servers (and websites) to security vulnerabilities. Additionally, you may miss out on new features or performance improvements. That’s why the first thing you’ll want to do is update your server package and download any pending security patches.
To get started, type the command apt update and press Enter. Now, your server will double check which packages need updating. Once done, enter apt upgrade, which will upgrade your server packages:
Run the dist-upgrade command.
This process may take some time, depending on the number of updates required for the server installation. So sit down, have a coffee and wait for it to finish.
Once all your packages are updated, you should go ahead and restart your server using the restart command. Then, close the command line window. Wait a minute or two and log back in using PuTTY (or your favorite customer).
If all goes according to plan, there should be no more available updates listed. This means we can move on to the next step to learn how to set up a VPS.
Step 3: Create a new user and change their privileges
When setting up a VPS, you start with the 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 a root account can cause severe damage if you are not sure what you are doing. The root account has full access to all settings on your system, so one wrong command can cause serious problems.
Normal user accounts with superuser rights, on the other hand, must add a sudo prefix to any command that wants to be run using administrator rights. It may seem like a small change, but it makes a big difference. With this approach, you should think twice before running any command using the sudo prefix, which can help you avoid crashes.
Go ahead and setup that new user now by entering the following command. We recommend replacing the second part with the username you want to use:
add your new username user
Then, type this line to add that user to the sudo group, which will give them superuser rights (again, replace the placeholder with your new username):
# usermod -aG sudo your new username
Now all that’s left is to set a password for this as a file on your computer. After setting up public key authentication, you will need a private key and passphrase to log in, which greatly increases security.
To generate an SSH key in Windows, you can use the PuTTYgen application, which was installed during the previous client setup (for details on how to do this on Linux/Unix systems, see this guide). Look for it in your program and now run the PuTTYgen application, which should look like this:
It’s fine to use the default settings for your key pair, so go ahead and click the Generate Now button. To make your keys even more unique, the program will ask you to move your mouse to shuffle them, which is pretty cool:
Shuffle your keys.
Next, the program will show you the public key it generates for you. Before you do anything else, go ahead and have an accompanying passphrase ready, which will act as the password along with the key:
4. Step 4 Set up a passphrase for your 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 bit, so don’t close this window just yet.
Then, log back into your server using the original root user and change to your new account’s home directory using # su – your new username. The command line will now reflect your new user:
Switch users via command line.
Next, you have to run a series of commands in succession, which will create a new folder for your public key, restrict the permissions of that folder, and save your key:
mkdir ~ / .ssh
chmod 700 ~ / .ssh
nano ~ / .ssh / authorized_keys
This last command will open the Nano editor, allowing you to edit a new author_keys file on your server. Go ahead and copy your public key now from the PuTTYgen window and paste it here.
Once the key is ready, press CTRL + X to close the editor and enter Y when it prompts you to confirm changes to the file. Then, type the following two commands:
chmod 600 ~ / .ssh / authorized_keys
That will change the permissions for the file you just edited, then return you to the root user.
Next, you need to configure PuTTY to use your private key when you connect to your server so it can recognize you. To do this, return to the main screen of the application and go to the Connection SSH› Auth section. Inside you will find a field called Private key file for authentication:
Upload the private key file.
Click the Browse button, then locate the private key file stored on your computer. Choose 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 this, login to your server as a 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 says PasswordAuthentication in that file and remove the previous #. Then change the value from Yes to No, so it reads like this:
n password authentication
Save the changes to a file and restart the server. The next time you try to log in, you can only log in using your private key and passphrase.
Step 5: Set up a firewall for your VPS
So far we’ve covered a lot about how to set up a VPS. However, there is still one final step to take if you want to keep your server secure. That is to enable the firewall for this.
You can do this by using the iptables program, which allows you to set rules that limit traffic to and from your server. This process is a bit tricky, 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 overwhelming at first. However, with Iptables, you will be able to limit the ports that allow traffic to access your server. This will stop many attacks in their tracks. Also, this is a one-time setup process, so it’s best to do it right away.
Pencarian Berdasarkan Kata Kunci
- format gambar jpg/jpeg