How to Install and Configure SSH on CentOS Linux

In this short tutorial we will see how to install and configure ssh server or client under CentOS Linux operating systems ! What is ssh ?  Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Secure Shell provides strong authentication and secure encrypted data communications between two computers connecting over an insecure network such as the Internet. CentOS packages required:

  • openssh-clients : The OpenSSH client applications
  • openssh-server : The OpenSSH server daemon
How to install them ? Use yum package installer:
yum install openssh-server openssh-clients -y
  • quite easy, the -y will advance the agree part.
Start and configure
chkconfig sshd on
service sshd start
  • chkconfig will set sshd to start on reboot.
Verify the service is running
netstat -tulpn | grep :22
All ssh traffic on your host by editing the firewall rules
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT"  /etc/sysconfig/iptables
  • or edit the file and type it in.
  • this rule will open for all hosts.
If you wanna restrict access use the bellow code:
-A INPUT -s 112.111.1.0/24 -m state --state NEW -p tcp --dport 22 -j ACCEPT
  • make sure you point to the right ip/mask
Note: - you need to restart you firewall after you edit the ip rules.
service iptables restart
More advanced ssh configurations can be done by editing the  /etc/ssh/sshd_config file  Configuration changes such as :
  • restrict root access by password.
  • restrict a specific user
  • change ssh port
-more configurations can be applied and changed as per your need. hope this was useful..