To configure SSH (or Secure Shell) we must understand that has become the standard for remote access, replacing the telnet protocol. SSH has made protocols like telnet redundant, mostly due to the fact that the connection is encrypted and passwords are not sent in plain text for everyone to see.
Firts thing first we install the OpenSSH server with the command:
sudo yum install openssh-server
Configure SSH
We edit the / etc / ssh / sshd_config file
First we make a backup of the original file.
sudo cp / etc / ssh / sshd_config /etc/ssh/sshd_config.old
We restrict the root user from being able to connect remotely.
PermitRootLogin no
We change the default port from 22 to 2244.
We restart the OpenSSH server.
sudo systemctl reload sshd
For the OpenSSH server to start automatically when the CentOS 7 Operating System is turned on.
sudo chkconfig sshd on
Create user for SSH to connect remotely we are going to create a new user.
sudo adduser userpublico
sudo passwd userpublico
To configure the Firewall we open the port that we change.
sudo firewall-cmd –permanent –add-port = 2244 / tcp
And we restart the Firewall.
sudo firewall-cmd –reload
Test SSH connection from another machine we execute this command to log in remotely with the new user, where 192.168.1.20 is the IP of the OpenSSH server.
ssh -p 2244 userpublico@192.168.1.20
And ready our SSH will already be configured in our CentOS system.