How to configure OpenSSH server in Linux

OpenSSH as popularly known is used for gaining secure access to remote computer and gain terminal access and transfer files. OpenSSH is set of client server program where all communication between client and server is encrypted. Since all communication is encrypted in OpenSSH, this makes it more secure than other similar tools like telnet or ftp. This is very helpful if you want to control several computers from single computer.

Installation SSH server in Linux

Use default installer in case RHEL/Fedora/Centos use yum for installation

yum -y install openssh-server openssh-client

In latest distribution of RHEL/Fedora/Centos DNF is used as default package manager, in this case use command

dnf install httpd-manual -y

Once installation of server and client is done, you will need to configure your client. Note that client is required for connection of remote server i.e. the system from which you are going to connect remote server must have client software installed.

Configure OpenSSH server

Although no specific configuration is required for connecting OpenSSH server. Still you can change port used for making connection enhance security, also you may disable remote root login.

Disable remote root login

Open the sshd_config file with your favourite text editor, its located in /etc/ssh/sshd_config. Now you have to change PermitRootLogin directive to no.

PermitRootLogin no

Change port for connecting OpenSSH server

To change port you have to change directives it. Open configuration file in editor and find line for ports and change it number desired.

# What ports, IPs and protocols we listen for
Port 79

After making any changes in configuration file you need restart you OpenSSH server.

Restarting OpenSSH server

To restart OpenSSH server you need to use your default service manager to restart it. Most of latest distributions of Linux are using systemctl

systemctl restart ssh restart

In case you are using an older distribution use

/etc/init.d/ssh restart

Now all you need is IP address of system and client software to connect to system using SSH.