{"id":61407,"date":"2021-03-26T08:31:15","date_gmt":"2021-03-26T14:31:15","guid":{"rendered":"https:\/\/www.scalahosting.com\/blog\/?p=61407"},"modified":"2025-11-21T14:28:16","modified_gmt":"2025-11-21T20:28:16","slug":"6-easy-steps-to-configure-your-first-vps-server","status":"publish","type":"post","link":"https:\/\/www.scalahosting.com\/blog\/6-easy-steps-to-configure-your-first-vps-server\/","title":{"rendered":"How to Configure Your First VPS Server in 6 Steps (Beginner&#8217;s Guide 2025)"},"content":{"rendered":"\n<p>Not sure how to configure your new VPS? You&#8217;ve come to the right place.<\/p>\n\n\n\n<p>This step-by-step guide has helped thousands of website owners get their virtual servers up and running, and now, it&#8217;s going to help you as well. Even if you&#8217;ve never managed a virtual server before, you can follow the instructions and <strong>get your project underway in less than an hour<\/strong>.<\/p>\n\n\n\n<p>We haven&#8217;t got much time to lose, so without further ado, let&#8217;s take a closer look at the steps.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Access the Server via SSH<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full mpg-gallery\"><img decoding=\"async\" width=\"1140\" height=\"300\" src=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-SSH-1140x300-1.webp\" alt=\"How to Configure Your First VPS Server in 6 Steps (Beginner&#8217;s Guide 2025), 1. Access the Server via SSH\" class=\"wp-image-72751\" srcset=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-SSH-1140x300-1.webp 1140w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-SSH-1140x300-1-300x79.webp 300w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-SSH-1140x300-1-768x202.webp 768w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n\n\n\n<p>A typical VPS supports many communication protocols, but the one you need to use in this case is SSH.<\/p>\n\n\n\n<p>SSH stands for <strong>Secure Shell<\/strong>, and it&#8217;s designed to allow you to <strong>execute commands remotely<\/strong>. It uses <strong>encryption <\/strong>to protect the communication between your home computer and your virtual server and ensure no one can see the information being exchanged.<\/p>\n\n\n\n<p>Establishing an SSH connection is pretty straightforward.<\/p>\n\n\n\n<p>If your home computer uses a <strong>Unix-based operating system <\/strong>like Linux or macOS, you can use the <strong>Terminal<\/strong>. On a Windows machine, you can open a shell with either<strong> PowerShell or the Command Prompt (cmd.exe)<\/strong>.<\/p>\n\n\n\n<p>The built-in tools do the job, but many people still prefer to use dedicated <strong>SSH client applications like PuTTY <\/strong>because of their convenient features. These apps can save sessions, store keys, and remember credentials for you, saving you a lot of time when connecting to your server.<\/p>\n\n\n\n<p>Accessing the VPS via SSH for the first time requires the login credentials provided by your host. In the command line, you need to enter:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>ssh [username]@[server IP]<\/em><\/p>\n\n\n\n<p>The server will receive the request via <strong>port 22<\/strong>, identify the <strong>username<\/strong> (if you&#8217;re logging in with the root user, it&#8217;s &#8220;root&#8221;), and ask for your <strong>password<\/strong>. After you provide the correct details, the server will display a welcome message in the command-line interface.<\/p>\n\n\n\n<p>With that, you have logged into your new VPS for the first time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Update the Server<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full mpg-gallery\"><img decoding=\"async\" width=\"1140\" height=\"300\" src=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-UpToDate-1140x300-1.webp\" alt=\"How to Configure Your First VPS Server in 6 Steps (Beginner&#8217;s Guide 2025), 2. Update the Server\" class=\"wp-image-72752\" srcset=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-UpToDate-1140x300-1.webp 1140w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-UpToDate-1140x300-1-300x79.webp 300w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-UpToDate-1140x300-1-768x202.webp 768w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n\n\n\n<p>Keeping the software on your VPS up-to-date is a significant part of ensuring it&#8217;s fast, reliable, and secure. Updates include <strong>security patches <\/strong>for various vulnerabilities that occasionally crop up, as well as new features and performance enhancements. After your first login, it&#8217;s a good idea to ensure all the latest versions are installed.<\/p>\n\n\n\n<p>Different distributions use different package managers &#8211; the tools used for installing and managing software in Linux. Debian-based distributions like Ubuntu are usually equipped with <strong>APT<\/strong>, whereas most Red Hat-based systems like Rocky Linux and Fedora use <strong>DNF<\/strong>.<\/p>\n\n\n\n<p>Some legacy Red Hat-based distros still use the <strong>YUM <\/strong>package manager, in which case, you&#8217;ll need to replace <em>dnf<\/em> in the commands below with <em>yum<\/em>. That said, you&#8217;re unlikely to be using an operating system this old.<\/p>\n\n\n\n<p>The update process starts with refreshing the package lists and identifying new versions of the installed software. For <strong>Ubuntu<\/strong> and other <strong>Debian-based<\/strong> distributions, for example, you&#8217;ll use:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ apt update<\/em><\/p>\n\n\n\n<p>For <strong>Red Hat-based distributions<\/strong>, the command is:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ dnf check-update<\/em><\/p>\n\n\n\n<p>Next, you tell the server to <strong>install the updates<\/strong>.<\/p>\n\n\n\n<p>For Debian-based distributions, the command is:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ apt upgrade<\/em><\/p>\n\n\n\n<p>In Red Hat-based distributions, you need to use:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ dnf update<\/em><\/p>\n\n\n\n<p>The process may take a while. After the update, it&#8217;s a good idea to restart the server using the <strong><em>reboot<\/em><\/strong><em> <\/em>command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Set up a Firewall<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full mpg-gallery\"><img decoding=\"async\" width=\"1140\" height=\"300\" src=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-Firewall-1140x300-1.webp\" alt=\"How to Configure Your First VPS Server in 6 Steps (Beginner&#8217;s Guide 2025), 3. Set up a Firewall\" class=\"wp-image-72753\" srcset=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-Firewall-1140x300-1.webp 1140w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-Firewall-1140x300-1-300x79.webp 300w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-Firewall-1140x300-1-768x202.webp 768w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n\n\n\n<p>A firewall is a basic security feature present on almost any server. However, this doesn&#8217;t make it any less important.<\/p>\n\n\n\n<p>The firewall controls your VPS networking ports and decides what traffic passes through them. It filters incoming requests and <strong>ensures data integrity<\/strong>.<\/p>\n\n\n\n<p>You&#8217;d think that setting up a firewall yourself is tricky, but fortunately, this isn&#8217;t the case. Before we get to the actual steps, however, let&#8217;s take a closer look at the tools you will be using.<\/p>\n\n\n\n<p>The Linux ecosystem has produced several firewall solutions over the years, but the one that has fared the best is <em>iptables<\/em>. Because it has withstood the test of time so well, either iptables or its successor, <em>nftables<\/em>, is built into almost every Linux system nowadays.<\/p>\n\n\n\n<p>It&#8217;s a<strong> packet filtering<\/strong> and<strong> Network Address Translation<\/strong> system that works with the Netfilter framework to give you complete control over all traffic on your server. As their names suggest, iptables and nftables use <strong>tables<\/strong>. The tables contain <strong>chains<\/strong>, which, in turn, contain <strong>rules<\/strong>.<\/p>\n\n\n\n<p>The difference between the two is in the syntax.<\/p>\n\n\n\n<p>The use of tables, chains, and rules makes your firewall incredibly powerful, but the downside is that it&#8217;s not exactly straightforward to work with out of the box. Fortunately, there are a couple of firewall management applications that can make your life a whole lot easier. You&#8217;ll want to use them when setting up your virtual server.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>UFW<\/strong><\/li>\n<\/ul>\n\n\n\n<p>UFW stands for <strong>Uncomplicated Firewall<\/strong>, a user-friendly command-line utility that lets you control iptables&#8217;s rulesets with fewer commands and a more intuitive syntax. Although it can be used on Red Hat-derived operating systems, UFW is pre-installed and primarily aimed at <strong>Debian-based systems<\/strong>.<\/p>\n\n\n\n<p>If you don&#8217;t have it on your Debian server, you can easily install it with the following command:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ apt install ufw<\/em>&nbsp;<\/p>\n\n\n\n<p>If you&#8217;re not using the root account, you&#8217;ll need to add the <em>sudo <\/em>prefix to the front. It&#8217;s a good idea to <strong>remove any other firewall management tools<\/strong>. Otherwise, you risk hitting conflicts and potential stability issues.<\/p>\n\n\n\n<p>Another recommended step is to reset all UFW rules with the following:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ ufw reset<\/em><\/p>\n\n\n\n<p>At this point, it&#8217;s essential to enable SSH immediately, or you risk locking yourself out. The command is:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ ufw allow OpenSSH<\/em><\/p>\n\n\n\n<p>The next port of call is to set the default policy. The recommended settings block all incoming and allow all outgoing traffic. The commands are:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ ufw default deny incoming<\/em><br><em>$ ufw allow outgoing<\/em><\/p>\n\n\n\n<p>Blocking any incoming traffic is recommended as a security baseline. However, if you leave the settings in this state, your website won&#8217;t be accessible to the outside world. To ensure it is, you need to enable HTTP and HTTPS connections:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ ufw allow http<\/em><br><em>$ ufw allow https<\/em><\/p>\n\n\n\n<p>Some of you may notice that we&#8217;re not enabling FTP. That&#8217;s because SSH allows you to upload and manage files through a more secure <strong>SFTP <\/strong>connection. All you need to do is select the correct protocol in your FTP client when connecting to your server.<\/p>\n\n\n\n<p>With that, all essential services should be up and running. To double-check, run:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ ufw status<\/em><\/p>\n\n\n\n<p>Make sure everything looks good, and pay particular attention to SSH. If the protocol is disabled, you may get locked out. The changes take effect after you enable UFW.<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ ufw enable<\/em><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Firewalld<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Many people believe that Firewalld is just UFW for Red Hat-based distributions, but this is not strictly the case.<\/p>\n\n\n\n<p>The two utilities have different syntaxes and differ slightly in how they handle rules. Firewalld introduces zones that allow for <strong>more flexible control over incoming traffic<\/strong>. You don&#8217;t need to restart the service every time you make changes to the configuration, which in turn means that it&#8217;s easier to find GUI-based management tools for it.<\/p>\n\n\n\n<p>Overall, Firewalld is a more advanced firewall management utility with a broader range of features and traffic filtering mechanisms. However, the steps to set it up and configure it are similar.<\/p>\n\n\n\n<p>Your first job is to install Firewalld if you don&#8217;t have it already. On Red Hat-based systems, you do it via:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ dnf install firewalld<\/em><\/p>\n\n\n\n<p>&nbsp;Next, you need to start the service and ensure it fires up at every boot:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ systemctl start firewalld<\/em><br><em>$ systemctl enable firewalld<\/em><\/p>\n\n\n\n<p>By default, Firewalld allows all outgoing traffic, so to set up a secure baseline, you just need to set the default policy to block incoming requests. You can do that using:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ firewall-cmd &#8211;set-default-zone=drop<\/em><\/p>\n\n\n\n<p>It&#8217;s now essential to allow SSH connections and ensure you don&#8217;t lock yourself out. The command is:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ firewall-cmd &#8211;zone=public &#8211;add-service=ssh &#8211;permanent<\/em><\/p>\n\n\n\n<p>Yet again, HTTP and HTTPS are the other two services you need to allow:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ firewall-cmd &#8211;zone=public &#8211;add-service=http &#8211;permanent<\/em><br><em>$ firewall-cmd &#8211;zone=public &#8211;add-service=https &#8211;permanent<\/em><\/p>\n\n\n\n<p>Finally, reload the firewall to save all changes:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ firewall-cmd &#8211;reload<\/em><\/p>\n\n\n\n<p class=\"alert-green\"><strong>NOTE: <\/strong>If you&#8217;re not using the root user, all commands listed above must be preceded by the <em>sudo <\/em>prefix.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Create a New User<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full mpg-gallery\"><img decoding=\"async\" width=\"1140\" height=\"300\" src=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-CreateUser-1140x300-1.webp\" alt=\"How to Configure Your First VPS Server in 6 Steps (Beginner&#8217;s Guide 2025), 4. Create a New User\" class=\"wp-image-72754\" srcset=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-CreateUser-1140x300-1.webp 1140w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-CreateUser-1140x300-1-300x79.webp 300w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-CreateUser-1140x300-1-768x202.webp 768w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n\n\n\n<p>Until now, we&#8217;ve assumed you&#8217;re using the server&#8217;s <strong>root<\/strong> user.<\/p>\n\n\n\n<p>The root user in Linux is the system&#8217;s owner. Its privileges are unlimited \u2013 as long as you&#8217;re<strong> logged in as root<\/strong>, you can do anything with the server.<\/p>\n\n\n\n<p>Any small mistake could have dire consequences because of the elevated privileges, so creating a second account with <strong>superuser permissions<\/strong> is generally considered good practice. With it, you can still configure your server&#8217;s most important settings. Still, you&#8217;ll need to add the <strong>sudo<\/strong> <strong>prefix<\/strong> to every command, and you&#8217;ll have quite a few more warnings and prompts when performing tasks that require administrative privileges.<\/p>\n\n\n\n<p>It may seem like a minor difference, but there are a few reasons why you should consider doing it:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The root account has completely <strong>unrestricted access<\/strong>. The wrong command could do irreparable damage, and there are no warnings to make you think twice.<\/li>\n\n\n\n<li>Using the root account will leave <strong>no audit trail<\/strong>. Debugging is more problematic, and finding out what happened if a security breach occurs will be difficult.<\/li>\n\n\n\n<li>Root accounts are <strong>often targeted by brute-force attacks<\/strong>. The reason is that the default username is always &#8220;root.&#8221;<\/li>\n\n\n\n<li>A second user account gives you better access control. You can apply the principle of least privilege and revoke access or restrict it to specific commands.<\/li>\n<\/ul>\n\n\n\n<p>After you&#8217;re logged in as root, you can create a new user account with:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ adduser [the new user&#8217;s username]<\/em><\/p>\n\n\n\n<p>If the server doesn&#8217;t automatically ask you to set a password for the new user, you can do it with:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ passwd [the new user&#8217;s username]<\/em><\/p>\n\n\n\n<p>Next, you need to assign the new user account to the admin group. There are variations in the way Linux distributions treat users. In Debian-based systems like Ubuntu, the default admin user group is <strong><em>sudo<\/em><\/strong>. In Red Hat-based distributions like CentOS and Rocky Linux, however, it&#8217;s called <strong><em>wheel<\/em><\/strong>.<\/p>\n\n\n\n<p>Hence, if you use a Debian-based server, you need to enter:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ usermod -aG sudo [the new user&#8217;s username]<\/em><\/p>\n\n\n\n<p>And if your VPS runs on a Red Hat-based distribution, you need:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ usermod -aG wheel [the new user&#8217;s username]<\/em><\/p>\n\n\n\n<p>With a couple of additional commands, you can confirm that the process has been successful.<\/p>\n\n\n\n<p>First, switch to the new account with the following:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ su &#8211; [the new user&#8217;s username]<\/em><\/p>\n\n\n\n<p>Then, check whether the new user has superuser privileges with:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ sudo whoami<\/em><\/p>\n\n\n\n<p>The output should read <strong><em>root<\/em><\/strong>.<\/p>\n\n\n\n<p>You now have an account with superuser privileges, so you can safely<strong> disable SSH access for the original root user<\/strong>. This reduces the attack surface during a brute-force campaign against your server and helps you prevent a security breach that could have serious consequences.<\/p>\n\n\n\n<p>First, ensure the root user is logged out (you can use the <em>exit<\/em> command) and open a new SSH session using the account we just created.<\/p>\n\n\n\n<p>Disabling root SSH access means editing the primary SSH configuration file, so it&#8217;s a good idea to create a backup before you continue. Go to the root directory (the one denoted by a single forward slash \/) and enter the following:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ sudo cp \/etc\/ssh\/sshd_config \/etc\/ssh\/sshd_config_old<\/em><\/p>\n\n\n\n<p>Now, you can open the sshd_config file and make the necessary changes. You can use any text editing utility you want. In our example, we chose <strong>Nano <\/strong>because it&#8217;s renowned as one of the most user-friendly utilities of its kind. The command is:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ sudo nano \/etc\/ssh\/sshd_config<\/em><\/p>\n\n\n\n<p>After you provide your account&#8217;s password, Nano will open the SSH configuration file. Find the line that says:<\/p>\n\n\n\n<p><strong><em>PermitRootLogin yes<\/em><\/strong><\/p>\n\n\n\n<p>and change it to<\/p>\n\n\n\n<p><strong><em>PermitRootLogin no<\/em><\/strong><\/p>\n\n\n\n<p>If there is a <strong><em>#<\/em><\/strong> character at the beginning of the line, remove it. Press <strong><em>ctrl\/cmd + X<\/em><\/strong> to exit and save the changes when prompted. Finally, it&#8217;s time to restart the SSH service.&nbsp;<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ sudo systemctl restart sshd<\/em><\/p>\n\n\n\n<p>In some cases, you might need to use <em>ssh<\/em> instead of <em>sshd<\/em>. With that, you have a new superuser account, and the root user is disabled.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Change the Default SSH Port<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full mpg-gallery\"><img decoding=\"async\" width=\"1140\" height=\"300\" src=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-ChangePort-1140x300-1.webp\" alt=\"How to Configure Your First VPS Server in 6 Steps (Beginner&#8217;s Guide 2025), 5. Change the Default SSH Port\" class=\"wp-image-72755\" srcset=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-ChangePort-1140x300-1.webp 1140w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-ChangePort-1140x300-1-300x79.webp 300w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-ChangePort-1140x300-1-768x202.webp 768w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n\n\n\n<p><strong>Port 22<\/strong> <strong>is SSH&#8217;s default listening port<\/strong>. Users know that, and so do hackers.<\/p>\n\n\n\n<p>A strong password limits the risks to a certain extent, but it&#8217;s still better to ensure that the door the criminals are knocking on is locked.<\/p>\n\n\n\n<p>Yet again, we need to edit the primary SSH configuration file. If you don&#8217;t have a backup of it, create one now.<\/p>\n\n\n\n<p>After going back to the root directory, enter:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ sudo nano \/etc\/ssh\/sshd_config<\/em><\/p>\n\n\n\n<p>Locate the line that says:<\/p>\n\n\n\n<p><strong><em>Port 22<\/em><\/strong><\/p>\n\n\n\n<p>If there is a <strong>#<\/strong> character at the beginning of the line, remove it and replace <strong>22<\/strong> with <strong>any number<\/strong> <strong>between 1024 and 65535<\/strong>. Ports below 1024 are privileged and usually require root permissions, so it&#8217;s not a great idea to use them. The port you choose <strong>mustn&#8217;t be used by any other services<\/strong>.<\/p>\n\n\n\n<p>Your next job is to ensure your firewall accepts connections at that port.<\/p>\n\n\n\n<p>The exact command depends on your firewall management utility.<\/p>\n\n\n\n<p>For UFW, it&#8217;s:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ sudo ufw allow [the custom SSH port number]\/tcp<\/em><\/p>\n\n\n\n<p>And for Firewalld, it&#8217;s:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ sudo firewall-cmd &#8211;permanent &#8211;add-port=[the custom SSH port number]\/tcp<\/em><br><em>$ sudo firewall-cmd &#8211;reload<\/em><\/p>\n\n\n\n<p>Finally, restart the SSH service to ensure the changes take effect. The command is:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ sudo systemctl restart ssh<\/em><\/p>\n\n\n\n<p>for Debian-based distros and<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ sudo systemctl restart sshd<\/em><\/p>\n\n\n\n<p>for Red Hat-based systems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Generate SSH Keys<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full mpg-gallery\"><img decoding=\"async\" width=\"1140\" height=\"300\" src=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-GenerateKey-1140x300-1.webp\" alt=\"How to Configure Your First VPS Server in 6 Steps (Beginner&#8217;s Guide 2025), Generate SSH Keys\" class=\"wp-image-72756\" srcset=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-GenerateKey-1140x300-1.webp 1140w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-GenerateKey-1140x300-1-300x79.webp 300w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2021\/03\/How-to-configure-your-first-VPS-Server-in-6-Steps-GenerateKey-1140x300-1-768x202.webp 768w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n\n\n\n<p>Changing SSH&#8217;s default listening port protects your servers against automated scripts that scan the internet in an attempt to infiltrate random servers. However, to block <strong>targeted attacks<\/strong>, it&#8217;s best to beef up your <strong>authentication mechanism<\/strong> as well.<\/p>\n\n\n\n<p>The traditional username-and-password system can be efficient if you choose a strong enough password, but an SSH public-and-private key pair makes for a more secure setup. To use it, you first need to generate the said keys.<\/p>\n\n\n\n<p>In Windows, the easiest option is to use the <strong>PuTTYgen<\/strong> application bundled with the popular SSH client. After you open it and click <strong>Generate<\/strong>, it will use the random motions of the mouse cursor to create one public and one private key. You can also set a <strong>passphrase<\/strong> that works alongside the key pair for additional security.<\/p>\n\n\n\n<p>The private key remains on your computer, so you can click <strong>Save private key<\/strong> and decide where to store it. You&#8217;ll also need to upload the public one to your server, but before we get to that, let&#8217;s see how Linux and MacOS users generate their keys.<\/p>\n\n\n\n<p>Unix-based operating systems have a built-in utility called <em>ssh-keygen<\/em>, which allows them to create key pairs without installing additional software.<\/p>\n\n\n\n<p>The command for creating a key pair looks like this:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ ssh-keygen -t rsa -b 4096 -C &#8220;[your email address]&#8221;<\/em><\/p>\n\n\n\n<p>The Terminal will ask you to choose a file path for your private key. By default, it saves it in <em>~\/.ssh\/id_rsa<\/em>.&nbsp;<\/p>\n\n\n\n<p>Finally, it requests a passphrase, after which it saves your public and private keys in the same folder. The public key gets a <em>.pub <\/em>extension, so if the private one is saved as <em>~\/.ssh\/id_rsa<\/em>, the public will be stored in <em>~\/.ssh\/id_rsa.pub<\/em>. You can open it with Nano and see the public key. Now, you need to copy it to your server.<\/p>\n\n\n\n<p>Open a new SSH session and go back to your user&#8217;s home directory. This is the folder you land in after you log in, but you can ensure you&#8217;re in the right place by entering:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ cd ~<\/em><\/p>\n\n\n\n<p>If you enter <em>pwd <\/em>at this point, the output should be \/<strong><em>home\/[your account&#8217;s username]\/<\/em><\/strong>.<\/p>\n\n\n\n<p>Create a folder to host your public key and set the correct permissions for it:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ mkdir ~\/.ssh<\/em><br><em>$ chmod 700 ~\/.ssh<\/em><\/p>\n\n\n\n<p>Next, you need to create a file where you&#8217;ll paste your public key. Once again, we&#8217;ll use the Nano text editor:<\/p>\n\n\n\n<p class=\"alert-orange\"><em>$ nano ~\/.ssh\/authorized_keys<\/em><\/p>\n\n\n\n<p>Copy the public key and paste it in Nano. Save the file and exit.<\/p>\n\n\n\n<p>On Linux and MacOS, you log in through the Terminal as usual.<\/p>\n\n\n\n<p>If you use Windows, open PuTTY, go to its settings, and click <strong>Connection<\/strong> &gt; <strong>SSH<\/strong> &gt; <strong>Auth<\/strong>. In the <strong>Private Key File for Authentication<\/strong> field, select your private key and save the changes.<\/p>\n\n\n\n<p>If you don&#8217;t use other devices to log into your server, you can disable your account&#8217;s password authentication.<\/p>\n\n\n\n<p>To do that, you need to edit the SSH configuration file \u2013 <em>etc\/ssh\/sshd_config<\/em>. It&#8217;s as simple as changing the <strong>PasswordAuthentication<\/strong> value from <strong>Yes<\/strong> to <strong>No<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ScalaHosting Managed cloud VPS Benefits<\/h2>\n\n\n\n<p>Setting up your virtual server wouldn&#8217;t be a concern if you choose one of our <a href=\"https:\/\/www.scalahosting.com\/managed-cloud-hosting.html\"><strong>managed cloud hosting plans<\/strong><\/a>. With them, you&#8217;ll get a cloud VPS that is already<strong> pre-configured and ready to use<\/strong>. The operating system, firewall, and all other tools and utilities required to keep your website online are set up by ScalaHosting&#8217;s experts. You don&#8217;t need to think about finding the right command, applying the correct settings, or enforcing the best firewall rules. Instead, you can focus on building your new website.<\/p>\n\n\n\n<p>And to do it, you won&#8217;t need to open even a single SSH connection. Secure shell is supported and available to all users on the server, and you can even request root access if you need to tweak the server&#8217;s core settings. However, you also have a much more user-friendly alternative &#8211; <a href=\"https:\/\/www.scalahosting.com\/spanel.html\"><strong>SPanel<\/strong><\/a>.<\/p>\n\n\n\n<p>SPanel is a unique server management platform that allows you to manage everything from files, databases, and email accounts to services, DNS settings, and some core server settings.<\/p>\n\n\n\n<p>Instead of executing complex commands, you click buttons, enable toggle switches, and select values from drop-down menus. You get access to every conceivable feature to easily start and develop your project. Even if you have no previous server or website management experience, you&#8217;ll get used to the interface in no time.<\/p>\n\n\n\n<p>If you need more information regarding our services, do not hesitate to contact our sales specialists.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Configuring a self-managed VPS is not a set-and-forget task.<\/p>\n\n\n\n<p>It&#8217;s up to you to ensure the machine performs at its best at all times, which isn&#8217;t exactly straightforward. Provided you invest enough time and effort \u2013 you can master the VPS operation and run your server without breaking a sweat.<\/p>\n\n\n\n<p>If manually configuring a virtual server is not your cup of tea, leave it to the professionals and opt for a first-class managed VPS solution.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<p><strong>Q:<\/strong> <strong>How does a VPS work?<\/strong><\/p>\n\n\n\n<p><strong>A:<\/strong> With<strong> guaranteed hardware resources <\/strong>and a<strong> dedicated IP<\/strong>, a VPS acts as a completely separate server instance, so configuring it involves the same steps as setting up a regular server \u2013 choosing an operating system, installing essential software, security monitoring, etc.<\/p>\n\n\n\n<p><strong>Q:<\/strong> <strong>How do I connect to a VPS?<\/strong><\/p>\n\n\n\n<p><strong>A:<\/strong> You can connect to your VPS through various protocols, but the one you&#8217;ll use to execute commands is <strong>SSH<\/strong>. It provides an <strong>encrypted connection<\/strong> through which you can communicate with the server&#8217;s operating system and perform a wide range of tasks.<\/p>\n\n\n\n<p><strong>Q:<\/strong> <strong>What is a VPS used for?<\/strong><\/p>\n\n\n\n<p><strong>A:<\/strong> Typically, managed VPS packages are optimized for hosting websites. You get a control panel with various features for managing files, folders, databases, etc. If you opt for a self-managed solution, you <strong>get root access <\/strong>and can install pretty much any software you want. A self-managed machine can easily turn into a <strong>gaming server<\/strong>, a <strong>mail server<\/strong>, an <strong>app server<\/strong>, or whatever else you need.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Not sure how to configure your new VPS? You&#8217;ve come to the right place. This step-by-step guide has helped thousands &#8230;<\/p>\n","protected":false},"author":113,"featured_media":61409,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_seopress_robots_primary_cat":"none","_seopress_titles_title":"How to Configure Your First VPS Server in 6 Steps %%sep%% %%sitetitle%%","_seopress_titles_desc":"Got your first-ever VPS server? It's time to configure it. Check out our comprehensive guide to learn how.","_seopress_robots_index":"","footnotes":""},"categories":[61],"tags":[],"class_list":["post-61407","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-hosting"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/posts\/61407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/users\/113"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/comments?post=61407"}],"version-history":[{"count":13,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/posts\/61407\/revisions"}],"predecessor-version":[{"id":73281,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/posts\/61407\/revisions\/73281"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/media\/61409"}],"wp:attachment":[{"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/media?parent=61407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/categories?post=61407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/tags?post=61407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}