VPS or virtual private server uses virtualization technology to split one powerful server into multiple virtual servers. As the name suggests, the server is for your private use. Experts always recommend shifting to a VPS as it is more secure, useful in handling high traffic volumes and causes lesser errors.
The majority of the web servers run on Unix-based systems. According to Matthew Orwell, an academic expert who provides Computer assignment help, “If you are willing to set up a VPS, you need commands that are compatible with the OS.” Unfortunately, you cannot do that with your Windows system. Here are 5 not-so-simple steps that can help you to set up a virtual private server for your website.
- Step 1: Log in to your VPS via Secure Shell Access:
FTP, which stands for File Transfer Protocol, can be used to upload, download, and edit the files on your server. The protocol also allows you to issue commands to your server. In order to do that, you will need Secure Shell (SSH) access, which is a different type of protocol that offers access to remote servers. SSH is known for being highly secure because of its strong encryption and authentication protocols.
Once you sign up for a VPS plan, your web host should provide you with these following credentials:
- The IP address for your server
- A user name (generally root)
- A password for the root account
While setting up the VPS, you will be starting off with a single root account. And that is the one you have to use to establish the initial connection. As long as you are using the Unix-based OS, you can connect your server directly from the command line. For Windows, you need to install an SSH client first. Both Bitvise and PuTTY are great options to choose from.
Once you have chosen the SSH client, and installed it, you will see a configuration window. You need to enter your server’s IP address into the Host Name (or IP address) and set the Port setting to the default value of 22. Also, mark the connection type to SSH and then click on the Open button. Once the command line window opens, you will be asked to enter the login information. If the login information is correct, you will get to see the brief summary of your server’s details, with a prompt to enter more commands.
- Step 2: Update the server:
Once you are logged in to your VPS, you will find a message that will tell you if there’s any “packages” or security updates available. Packages are basically software in Unix system, and if you want the system to run smoothly, you need to make sure every component, including the server is up to date. To get started, you need to type in the apt update command and hit Enter.
After entering the apt update command, your server will run diagnosis to see which packages need upgrading. Once the checking is done, enter apt dist-upgrade, which will initiate the update of the server’s packages. The process may take a significant amount of time depending on the number of updates. Once the packages are up to date, you should restart your server using the reboot command. Now, you can close the command line window, and wait 2 minutes and log back in using the SSH.
- Step 3: Create a new user account and modify its privileges:
As mentioned, you need to start off with a root user. However, it is recommended to set up another user account with superuser privileges. The root account can do more harm than good if you are not sure what you are doing. Since the root account has access to all of your system’s settings, one wrong command can create a lot of problems.
On the other hand, setting up an account with superuser privileges cannot run any command using administrative privileges without the prefix sudo. This may seem insignificant to you in the beginning, but it can actually save you from messing things up. So, set up new user name using the command adduser abcd. You can use any name in place of “abcd” while naming the new account.
Once that is done, type the following command to add the user (which is named abcd here) to the sudo group, which will give it the superuser privileges.
# usermod -aG sudo abcd
When you are done adding the account to the sudo group, it is time to set up the password.
- Step 4: Enable public key authentication:
Public key authentication offers more secure passwords than the regular ones. Also, this process allows the user to generate both “public” and “private” keys. Generally, the server stores the public key and authenticates the private one. But when you set up the public key authentication, you will require both keys and a passphrase to log in.
In order to generate SSH keys in Windows system, you can use the key generator app which was installed during the set up of the SSH client. If you have installed PuTTY SSH (which is highly recommended), you can use the PuTTYgen app to generate your key pair. Click on the Generate button and move around your mouse to generate a unique key.
Now, the program will display the public key it has generated for you. However, you should set up an accompanying passphrase for the key before doing anything else. This passphrase will work as a password alongside the key. Once the passphrase is set up, click on the Save private key button and save the file on your computer. Don’t close the window yet, as you need to copy your public key very soon.
Now, log back into the server using the original root account, and move to the new account’s home directory using the following code
# su – abcd
Now that the command reflects on your new account, you need to run a series of commands to perform these following actions:
- Create a new folder for the public key
- Restrict that folder’s permission
- Save the key
The commands are:
chmod 700 ~/.ssh
With the last command, you will get access to the Nano editor which will allow you to modify the new authorized_keys file on the server. Now, you can go and copy the public key from the PuTTYgen window and then paste it in the editor. Once the key is ready, press CTRL + X to close the editor, and enter Y, when it asks you to confirm the changes made in the file. After that, type in the following commands:
chmod 600 ~/.ssh/authorized_keys
These commands will change the permissions for the file you have edited and then return you to the root user. Next, you need to configure PuTTy to use your private key when you choose to connect to your server. This allows the SSH client to recognize the user.
To perform this, return to the main screen of the app and go to Connection › SSH › Auth section. You will find a field called Private key file for authentication. Once you find the field, click on the Browse button, and then locate the private key file you have saved on the computer. Select the file and you are almost done. Just tell your server to disable the default password-only authentication methods for the new account you have set up. To do that, you need to login to the server as the new user using the SSH and run the following command:
sudo nano /etc/ssh/sshd_config
This will open the sshd_config file using the Nano editor that we have discussed before. Now, look at the line that reads PasswordAuthentication inside the file, and remove the # sign. Finally, change its value from Yes to No, so that it reads PasswordAuthentication no.
Save the changes to the file, and reboot your server. The next time you want to login to the server, you can use the private key and the passphrase.
It is recommended to enable a firewall for the VPS to keep the server secure. Now that you know how to configure your VPS, you can manage your website traffic with ease. Here’s wishing you all the best with your endeavors.
Suhana Williams is an academic writer who also provides assignment help through Assignmenthelp.us. She has contributed to several journals with her insight on placement opportunities in the modern era. Suhana loves to cook when she is not working.