[Updated] SSH or Secure Shell is a network communication protocol that enables two computers to communicate. It is one of the simplest and most sensitive services to install on a Linux Server, and of course, security considerations. As an administrator or even a user, this network gives you a secure way to access a computer over an unsecured network. SSH is using to establish a secure and direct connection between two computers. Also, to ”log in” and perform operations on remote computers, and sometimes to transfer data you will need to use SSH. This article presents Install SSH Server On Linux And Allow Root User Login. Choose and order your own Linux VPS by visiting various packages on Eldernode.
Tutorial Install SSH Server On Linux And Allow Root User Login
SSH enables you to provide a service with encrypted access for Linux. SSH is originally a Unix application and is also implemented on all Linux distributions and macOS. However, SSH can also be used on Windows, if you install a relevant program. In the following, you will learn more about SSH, the way you can install SSH on Linux.
Prerequisites to Install SSH on Linux
To let this tutorial work better, please consider the below Prerequisites:
_ Root access to your server
_ Terminal (Linux)
What is SSH Server and Why you need it?
Secure Shell is part of the operating system. It provides secure network services and strong password authentication and public key authentication, as well as encrypted data communications between two computers connecting over an open network, such as the internet. Data, Commands, Texts, and Files could be transferred with SSH.
The Shell is the text-based command line, terminal, or console. The graphical user interface is also called a shell. SSH enables the same functions such as logging in to and running terminal sessions on remote systems. You can use the secure shell instead of the insecure terminal emulation or login programs, such as Telnet, remote login, and remote shell. Using SSH allows you to have an encrypted connection and make sure if connections are established between the designated computers.
Let’s review some of the Differences between SSH and OpenSSH:
1- As you read above, OpenSSH is free and Open-source. But SSH is a closed source cryptographic network protocol.
2- While SSH was released in the year 1995 as SSH-1 protocol and tries to replace TELNET, rlogin, ftp, and rsh protocols, OpenSSH was released in the year 1999, is not a protocol and is created for free software fans.
3- The most used commands of SSH are ssh, ssh-keygen, ssh-agent, ssh-keyscan, scp, sftp, and sshd. And The most used commands of OpenSSH are Ssh-keygen, ssh-copy-id, ssh-add, ssh-agent, scp, sftp, and sshd.
How To Install SSH Server On Linux
First of all, you will need to get familiar with OpenSSH. OpenSSH is a free open-source set of computer tools used to provide secure and encrypted communication over a computer network by using the ssh protocol. It was initially developed as a part of the OpenBSD operating system and provides secure communication. Notice that OpenSSH is not a protocol and it is a set of computer programs that use the ssh protocol.
In order to get SSH on the server, you need to run the OpenSSH package. OpenSSH is pre-installed on various versions of Linux for both the client-side as well as server-side. However, you need to use Ubuntu as an Operating system to be able to install OpenSSH on Linux and check if it is installed. To install OpenSSH on Debian, Ubuntu, or Linux Mint, use the command below:
sudo apt-get install openssh-server openssh-client
Once the installation of packages is finished, tun the following command to check if the service is running:
service sshd status
How to configure OpenSSH On Linux
to start configuring OpenSSH, you need to edit the /etc/ssh/sshd_config file. so, make a copy of the original file and then configure OpenSSH. To do this, open a terminal and run the command below to make a copy of the original sshd configuration file:
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original_copy
In case of my mistake, you will be able to change your desired settings on the copied file and reuse it.
How to connect to OpenSSH
When you pass the installation and configuration steps correctly, it is time to check if your OpenSSH server is working well. To do this, you can use the Netcat tool by running the following command:
nc -v -z 127.0.0.1 22
Also, you can use another way to connect to OpenSSH by connecting it from your localhost through your OpenSSH client or do a portscan with Nmap.
Or in your client computer, use the following command to connect using SSH.
Note: Use the username of the remote computer and the IP address.
Once you faced the warning of ”Are you sure you want to continue connecting (yes/no)”, type yes. then, if you type the password of your user at the remote computer, you will be logged in to a remote Linux computer.
The service runs on TCP port 22 by default, but you can change it. To set your OpenSSH to listen on TCP port 13, open the sshd_config file with your favorite text editor and run:
What ports, IPs and protocols we listen for Port 13
To let the changes in the config file take place, run the following command and restart the OpenSSH server:
sudo /etc/init.d/ssh restart
After restarting the OpenSSH, you can check if the changes in config files were done and if the OpenSSH server listening to port 13 or not. To do this again use a netcat command:
nc -v -z 127.0.0.1 13
And finally, modify the content of the /etc/issue.net file and add the below line inside the sshd configuration file if you wish to have your OpenSSH server display a nice login banner:
How to allow Root user login on Linux
Now, you can enable SSH root login by opening the file /etc/ssh/sshd_config:
Then, search for the following line and put the ‘#‘ at the beginning, and save the file.
Next, to restart the sshd service, run:
At this point, you should be able to log in with the root user.
In this article, you learned how to install and use OpenSSH on Linux. Then, you reviewed the way of enabling SSH root login. Notice that if you have a large number of user accounts on the systems, you can limit SSH user logins. If you are interested to learn more, refer to Enable root login via SSH in Ubuntu 20.04 and Debian 10.