How to install and configuration openssh-server in centos 6

Step 1

# yum -y install openssh-server
chkconfig sshd on
service sshd start
service sshd statut

Step 2

# nano /etc/sysconfig/iptables
-> Add the line :
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1235 -j ACCEPT
-> If you want to restict access to 192.168.1.0/24, edit it as follows:
-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 1235 -j ACCEPT
# service iptables restart

نکته : به صورت پیشفرض خطی جهت اتصال به سرور از روی پورت 22 وجود دارد، با توجه به این که قصد تغییر پورت پیش فرض را داریم لذا عدد 22 خط موجود را تغییر می دهیم یا رول خود را جایگزین این خط می کنیم.


Step 3

# echo 'PermitRootLogin no' >> /etc/ssh/sshd_config
# echo 'AllowUsers centos' >> /etc/ssh/sshd_config
# echo 'Port 1235' >> /etc/ssh/sshd_config
# service sshd restart