<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hadi Samadzad</title>
    <description>The latest articles on DEV Community by Hadi Samadzad (@hadisamadzad).</description>
    <link>https://dev.to/hadisamadzad</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F312716%2F781e41af-015a-4364-8958-a01291f72194.jpg</url>
      <title>DEV Community: Hadi Samadzad</title>
      <link>https://dev.to/hadisamadzad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hadisamadzad"/>
    <language>en</language>
    <item>
      <title>6 Tips to Use SSH Client Effectively For Connecting To Linux Servers</title>
      <dc:creator>Hadi Samadzad</dc:creator>
      <pubDate>Fri, 03 Feb 2023 17:11:47 +0000</pubDate>
      <link>https://dev.to/hadisamadzad/6-tips-to-use-ssh-client-effectively-for-connecting-to-linux-servers-2fok</link>
      <guid>https://dev.to/hadisamadzad/6-tips-to-use-ssh-client-effectively-for-connecting-to-linux-servers-2fok</guid>
      <description>&lt;p&gt;SSH is the most common tool to connect to a VPS. If you are someone who connects to servers as a part of their role, I have listed 6 easy-to-use and practical tips to make your experience more secure and productive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx9l3px8lfxs16zu8rqjh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx9l3px8lfxs16zu8rqjh.png" alt="Photo by Christina @ wocintechchat.com on Unsplash"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tip 1- Create SSH Profiles
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;SSH&lt;/em&gt; profiles are an interesting way to make it easy to connect to a server using SSH. Let's say you are using a custom username and port number to connect to your server, so each time you would like to connect to the VPS, you need to use ssh command like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="o"&gt;[&lt;/span&gt;USERNAME]@[IP_ADRESS] &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;PORT_NUMBER]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finding and entering these &lt;code&gt;ssh&lt;/code&gt; parameters each time can be frustrating. Instead, you can simply create a profile using the SSH config file, so the next time, you can connect using the profile name rather than connection info. Profiles are stored in the &lt;code&gt;~/.ssh/config&lt;/code&gt; file. The below code snippet shows the corresponding configuration for the above-mentioned connection info.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host [PROFILE_NAME]
    HostName [IP_ADDRESS]
    User [USERNAME]
    IdentitiesOnly yes
    IdentityFile ~/.ssh/id_rsa
    Port [PORT_NUMBER]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can access the VPS only with the profile name benefiting auto-completion. Enjoyed it? jump to the next one to get more fun.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="o"&gt;[&lt;/span&gt;PROFILE_NAME]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Tip 2- Connect without a Password
&lt;/h2&gt;

&lt;p&gt;Although having a strong password can effectively increase the security level of your VPS, recalling it each time you want to log in can be frustrating. The good news is that if you are using specific machines to log in to your servers, you can set a public/private key pair so that you don't need to provide a password each time.&lt;br&gt;
First, you should generate an ssh key pair on your local machine; then, press enter button a couple of times until they are generated (These steps are to set a location, a filename and a passphrase but they can remain default).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create a key pair&lt;/span&gt;
ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you need to copy the generated key to the remote server using &lt;code&gt;ssh-copy-id&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-copy-id &lt;span class="o"&gt;[&lt;/span&gt;USERNAME]@[IP_ADDRESS] &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;PORT_NUMBER]

&lt;span class="c"&gt;# or if you have already set a profile configuration&lt;/span&gt;
ssh-copy-id &lt;span class="o"&gt;[&lt;/span&gt;PROFILE_NAME]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Try to connect to the remote server and you should be logged in without being prompted for a password. Just keep in mind, you should not use key pairs on shared machines as can be a security vulnerability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tip 3- Block root Access
&lt;/h2&gt;

&lt;p&gt;Although some VPS hosting services provide connection configuration using an out-of-the-box admin user rather than root, generally, you will connect to the VPS using root access. Removing root access from SSH guarantees that the username must be provided at login time as root is the default username.&lt;br&gt;
&lt;strong&gt;Be careful&lt;/strong&gt; that before blocking the root access you need to create an admin user you are going to use instead of root. Otherwise, you may lose access to the VPS.&lt;br&gt;
Another plus for blocking root access is avoiding unintentional changes on the server as new admin user access can be limited. To create a new so-called &lt;code&gt;admin&lt;/code&gt; user on Ubuntu uses the below code snippet. As well, to prepare the created user for SSH login, you need to set a password as soon as you create that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Add a new user (e.g. admin)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;useradd &lt;span class="nt"&gt;-m&lt;/span&gt; admin

&lt;span class="c"&gt;# Set a password for new user&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;passwd admin

&lt;span class="c"&gt;# Add user to sudoers' list&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;admin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, to remove the root access you need to set &lt;code&gt;PermitRootLogin&lt;/code&gt; entry to &lt;code&gt;no&lt;/code&gt; in the SSH config file located in &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; and restart the &lt;code&gt;sshd&lt;/code&gt; service.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgvlkek74teuw38y485en.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgvlkek74teuw38y485en.png" alt=" raw `root` endraw  Login in SSH Config File"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Restart sshd service&lt;/span&gt;
systemctl restart sshd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;EDITED&lt;/strong&gt;-After implementing the previous tip, you might find it difficult to switch from admin to root by providing a password. You can do this much more simpler by removing the password prompt. To this end, you can add a new line of config to &lt;code&gt;/etc/sudoers&lt;/code&gt; file after &lt;code&gt;root ALL=(ALL:ALL) ALL&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;admin    &lt;span class="nv"&gt;ALL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;NOPASSWD:ALL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As well, you need to comment &lt;code&gt;%sudo ALL=(ALL:ALL) ALL&lt;/code&gt; line to be like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#%sudo  ALL=(ALL:ALL) ALL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you should be able to switch to root using su command. As a result, just after logging in with admin user, you can simply switch to root without getting any password prompt.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Swith to root user without providing password&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;su root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Tip 4- Changing SSH Port
&lt;/h2&gt;

&lt;p&gt;Changing the port number is a simple way to hide a VPS from crawlers. SSH uses port &lt;code&gt;22&lt;/code&gt; by default, however, you can simply modify it to any port number from &lt;code&gt;1024&lt;/code&gt; to &lt;code&gt;65,535&lt;/code&gt; (ports &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;1023&lt;/code&gt; are reserved). Nevertheless, using a 5-digit and uncommon port number is recommended. To do this, you can modify the port number in &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; by setting &lt;code&gt;Port&lt;/code&gt; entry and reset &lt;code&gt;sshd&lt;/code&gt; service.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9nejzu085imv2438m74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9nejzu085imv2438m74.png" alt="SSH Port Modification to  raw `22334` endraw "&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;NOTE -&lt;/strong&gt; Before updating the SSH port number, be sure that you have opened the new port number through &lt;code&gt;ufw&lt;/code&gt; if the firewall is already active. I you don't know what this means, please don't touch the port number until you have read &lt;code&gt;ufw&lt;/code&gt; tip in the below sections.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Restart sshd service&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart sshd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Tip 5- Block Unused Ports
&lt;/h2&gt;

&lt;p&gt;Although firewall configuration is not an SSH-related tip, it is worth mentioning as it is a crucial step when you are trying to connect to a VPS. Using a firewall in Ubuntu is not that much complex as you might expect. In Ubuntu, there is an out-of-the-box firewall named Uncomplicated Firewall and as can be inferred from its name it's easy to use. &lt;code&gt;ufw&lt;/code&gt; is the command-line tool for working with that. By activating &lt;code&gt;ufw&lt;/code&gt; you can control the network stream using different filters like ports and IPs. To this end, you can use &lt;code&gt;allow&lt;/code&gt; and &lt;code&gt;deny&lt;/code&gt; commands to manage a port.&lt;br&gt;
&lt;strong&gt;NOTE -&lt;/strong&gt; Before activating the firewall, make sure the SSH port is allowed (default port &lt;code&gt;22&lt;/code&gt; unless you have changed it before), otherwise, you will lose your access to the VPS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Open SSH port&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow ssh
&lt;span class="c"&gt;# - OR -&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow &lt;span class="o"&gt;[&lt;/span&gt;SSH_PORT]

&lt;span class="c"&gt;# Block a port&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw deny &lt;span class="o"&gt;[&lt;/span&gt;UNUSED_PORT]

&lt;span class="c"&gt;# Activate firewall&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw &lt;span class="nb"&gt;enable&lt;/span&gt;

&lt;span class="c"&gt;# Check firewall status&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw &lt;span class="nb"&gt;enable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Tip 6- Block ping Requests
&lt;/h2&gt;

&lt;p&gt;Similar to Tip 5, this topic is not related to SSH, but it's a simple yet effective action to elevate the server's security. Ping service responds to &lt;code&gt;icmp&lt;/code&gt; packets requested from a client and it is widely used to test whether a server is reachable over a specific IP address or not. However, it can be used by crawlers to find your server's IP address as you are responding to their &lt;code&gt;ping&lt;/code&gt; requests.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4avpsrso7b6vwcv4pn8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4avpsrso7b6vwcv4pn8.png" alt="Sample result of  raw `ping` endraw  command execution"&gt;&lt;/a&gt;&lt;br&gt;
To deactivate ping permanently (which means it won't be activated again after reboot) you need to switch to &lt;code&gt;root&lt;/code&gt; user and set &lt;code&gt;net.ipv4.icmp_echo_ignore_all = 1&lt;/code&gt; in &lt;code&gt;/etc/sysctl.conf&lt;/code&gt; file (append if it's not existing in the file) and run &lt;code&gt;sysctl -p&lt;/code&gt; command afterwards. In some Linux distros, you may notice that the setting is gone. In this case, you can try to append the same line of setting to &lt;code&gt;/etc/ufw/sysctl.conf&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Switch to root&lt;/span&gt;
su root

&lt;span class="c"&gt;# Append the config file&lt;/span&gt;
nano /etc/sysctl.conf
&lt;span class="c"&gt;# OR&lt;/span&gt;
nano /etc/ufw/sysctl.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16d5oryzqi50k4hkkyy3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16d5oryzqi50k4hkkyy3.png" alt="Modified  raw `sysctl` endraw  Config File"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ow sysctl &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you try to ping the server and make sure that it's working.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Words!
&lt;/h2&gt;

&lt;p&gt;These tips will help you to have a better experience in working with an SSH client. Keep in mind, if you find something tedious in your everyday work, you may find a better way to do that. Just be careful, in working with a VPS, a simple mistake may result in a major security risk or maybe a loss in your access to your server.&lt;/p&gt;

</description>
      <category>ssh</category>
      <category>linux</category>
      <category>vps</category>
      <category>security</category>
    </item>
    <item>
      <title>Beginners’ Guide To Run A Linux Server Securely</title>
      <dc:creator>Hadi Samadzad</dc:creator>
      <pubDate>Tue, 17 Jan 2023 00:40:52 +0000</pubDate>
      <link>https://dev.to/hadisamadzad/beginners-guide-to-run-a-linux-server-securely-2hn6</link>
      <guid>https://dev.to/hadisamadzad/beginners-guide-to-run-a-linux-server-securely-2hn6</guid>
      <description>&lt;h4&gt;
  
  
  Easy steps to Linux Server hardening for Linux newbies
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5nzjxtbupdejj6221ax2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5nzjxtbupdejj6221ax2.jpg" alt="Photo by [Gabriel Heinzer](https://unsplash.com/@6heinz3r?utm_source=medium&amp;amp;utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Linux could be a fantastic choice for your next cloud server. Imagine you can benefit from an up-to-date and fully-loaded operating system on a 90s hardware configuration of 512 MB and 1-core CPU. Apart from technical benefits, it is the cheapest option to have; so you may have decided to run your services on it. Although connecting to a server just using a single line command, keeping it secure could be a bit tricky. I will go through what you need to take some essential considerations for tackling common security risks with server hardening.&lt;/p&gt;

&lt;h3&gt;
  
  
  Choosing a Distro to Start
&lt;/h3&gt;

&lt;p&gt;Unlike Windows and macOS, Linux is a family of open-source operating systems and many different distros are published up to now. Some of the most popular Linux distros are &lt;em&gt;Red Hat&lt;/em&gt;, &lt;em&gt;CentOS&lt;/em&gt;, &lt;em&gt;Fedora&lt;/em&gt;, &lt;em&gt;Debian&lt;/em&gt;, &lt;em&gt;Ubuntu&lt;/em&gt;, &lt;em&gt;Kali&lt;/em&gt;, &lt;em&gt;Mint&lt;/em&gt;, etc. However, from a high-level point of view, there are two major family distros: &lt;em&gt;Red Hat-based&lt;/em&gt; and &lt;em&gt;Debian-based&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;For many Linux beginners, it is a matter of high significance to choose a distro as a starting point. Although you can take your time to thoroughly investigate different options, the best course would be just starting with one of them and be sure you will enjoy the taste of Linux with all of them. By the way, if you have no idea and just want to start, my recommendation is to choose Ubuntu thanks to its community and its myriad of available documents.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Ubuntu&lt;/em&gt; is a Debian-based Linux distribution introduced by Canonical in 2004. There are three editions of Ubuntu: &lt;em&gt;Desktop&lt;/em&gt;, &lt;em&gt;Server&lt;/em&gt;, and &lt;em&gt;Core&lt;/em&gt;. The second edition as its name shows is considered to be used for servers. Against the Desktop edition, Ubuntu Server doesn’t comprise any graphical user interface and you may use a command-line tool named &lt;em&gt;bash&lt;/em&gt; to manage the server.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connecting to Server
&lt;/h3&gt;

&lt;p&gt;No matter which provider you choose to buy a server from, after ordering a VPS you need to acquire its connection info. Generally, it should be dropped in your inbox as soon as you check out your order. All you need to connect and set up your machine are two things: the server’s &lt;em&gt;address&lt;/em&gt; and its &lt;em&gt;root&lt;/em&gt; &lt;em&gt;password&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To connect to the server, you may need an application that supports &lt;em&gt;SSH&lt;/em&gt; which is a protocol for communication between two computers. Does not matter if you are using Windows or macOS, you can connect to your server using the &lt;em&gt;ssh&lt;/em&gt; command in a command-line tool like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh [USER]@[SERVER_IP_Address]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Possibly, providers do not mention the username but you should know the username is root*. *By executing the ssh command, you will be prompted to insert the password and by providing that, you will log in to your fantastic server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2Asw_6-uGwvFlzC3rKqphZUw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2Asw_6-uGwvFlzC3rKqphZUw.png" alt="Ubuntu Server Terminal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you logged in, you can see a couple of information about the Ubuntu version and allocated hard disk capacity and can start loading your services, however, you may need to do further steps to secure your server as there are others intended to use your resources illegally without taking its responsibility. Therefore, it is crucial for you to apply at least some essential security measures on your newly bought machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Knowing The Threats
&lt;/h3&gt;

&lt;p&gt;Suppose an evil wants to use your machine without your allowance, what do they need? Yeah, the server IP address and the password.&lt;/p&gt;

&lt;p&gt;Although finding a combination of an unknown IP address and a random password might seem to be impossible, believe me, it is viable via a brute force tool as I have been a victim a couple of times. Just to have a clue check the server’s IP address using *ping *and you will see how a valid IP can be identified among many other invalid IP addresses.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ping [SERVER_IP_ADDRESS]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2ALAPc3jsxzfme9TeHrvdPBA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2ALAPc3jsxzfme9TeHrvdPBA.png" alt="Ping Command"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As soon as unauthorized access is attained, it is not predictable in which way they will use your resources with your responsibility. Let’s dive into some simple steps you can do to minimize the risks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding some security
&lt;/h3&gt;

&lt;p&gt;**Step 1 — Strong Password: **This is the first way that comes to mind. Based on password strength checker tools like &lt;a href="https://bitwarden.com/password-strength/" rel="noopener noreferrer"&gt;this&lt;/a&gt;, if you use a random password it should be at least 10 characters in length so that it takes 1 day to be found by bots. As well, it may be much easier if you use a pattern to create your password, so, go for a longer password in length.&lt;/p&gt;

&lt;p&gt;**Step 2 — Remove root access: **You can simply add another complexity to the SSH login by removing root access. This way, plus the IP address and password, the username must be provided to log in, as the default username which is root **is blocked. To this end, before blocking root access, you need to add a new sudoer user to the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Add a user
sudo useradd -m {username}

# Set a password for new user
sudo passwd {username}

# Add the new user to sudoers' list
usermod -aG sudo {username}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, you should disable root login from ssh_config (you may need to install nano using apt install nano):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Open SSH config file
nano /etc/ssh/sshd_config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Find PermitRootLogin, uncomment the line by removing # and set to no. The final state of this parameter should be as shown.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2Ak26hzEKAsxOWMJTh5auFiA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2Ak26hzEKAsxOWMJTh5auFiA.png" alt="Removing root login from *sshd* config file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, after saving the file you need to restart ssh service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl restart sshd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: For many operations on the server you need an sudo access; so after login using the new user, you can switch back to root using su command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;su root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 3 — Change *ssh *port number:&lt;/strong&gt; SSH uses a default port 22 which can be modified in the sshd_config config file. This change adds another complexity for connecting to the server because the port number has to be provided in the login. To this end, you must open the file again and change the value of Port to another number like 12345. Likewise, you need to restart ssh service again. Not to forget to mention that after changing the default port number you should provide that in the login.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -p [NEW_PORT_NUMBER] [USER]@[SERVER_IP_Address]
# example: ssh -p 12345 admin@8.8.8.8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;It is worth understanding how to tackle security risks. I mean, although it is difficult to guarantee that the server will be totally safe, adding complexity is a reasonable and effective approach for server hardening meaning that crawlers and bots must do much more effort to do their evil mean.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>beginners</category>
      <category>security</category>
    </item>
  </channel>
</rss>
