How To Install OpenSSH on Centos / RedHat

by lifeLinux on May 10, 2011

What is OpenSSH ?

OpenSSH is a FREE version of the SSH connectivity tools that technical users of the Internet rely on. Users of telnet, rlogin, and ftp may not realize that their password is transmitted across the Internet unencrypted, but it is. OpenSSH encrypts all traffic (including passwords) to effectively eliminate eavesdropping, connection hijacking, and other attacks. Additionally, OpenSSH provides secure tunneling capabilities and several authentication methods, and supports all SSH protocol versions.

Install OpenSSH under CentOS Linux

To install the server and client type the following command:

[root@lifelinux ~]# yum install openssh-server

Start the service:

[root@lifelinux ~]# service sshd start

Set sshd service to automatically start at boot time, type the following command

[root@lifelinux ~]# chkconfig sshd on

Check & Make sure port 22 is opened:

[root@lifelinux ~]# netstat -tulpn | grep :22

Sample outputs:

tcp        0      0 :::22                       :::*                        LISTEN      1703/sshd

OpenSSH Server Configuration

Now you need to edit the /etc/ssh/sshd_config file using vi or any other editor and you need to change the following Directives or add the following directives for OpenSSH server configuration these are only some of basic directives if you want to know available directives check here
To change SSH listening port, example change port to 2222

Port 2222

To disable root logins, edit or add as follows:

PermitRootLogin no

Allow only SSH protocol 2

Protocol 2

Allow only user1 and user2 over SSH:

AllowUsers user1 user2

Firewall Settings

Open /etc/sysconfig/iptables file, enter:

[root@lifelinux ~]# vi /etc/sysconfig/iptables

Add the following line

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

Save and close the file. Restart the firewall:

[root@lifelinux ~]# /etc/init.d/iptables restart

Related Posts:

Previous post:

Next post:

than bai 3