How to Allow and Deny Access for Remote SSH to CentOS 6.2

Share this Article :

In this post, i will show on how to allow and deny access for Remote SSH to CentOS server. This post will configure SSH access as follows:
– Only ehowstuff and root has remote SSH access to the machine within ehowstuff.local
– Clients within should NOT have access to ssh on your system

Please note that all systems in that domain are in the subnet, and all systems in that subnet are in

Also Read :   How to Configure Basic Setup for lighttpd on CentOS 6.3

1. Modify ssh_config as below :

[[email protected] ~]# vi /etc/ssh/sshd_config
AllowUsers ehowstuff root

2. Make sshd auto start on boot and restart sshd service :

[[email protected] ~]# chkconfig sshd on
[[email protected] ~]# /etc/init.d/sshd restart

3. Open iptables configuration as below :

[[email protected] ~]# vi /etc/sysconfig/iptables

4. Append this line on your iptables setting :

-A INPUT -s -p tcp --dport 22 -j REJECT

5. Restart the iptables :

[[email protected] ~]# /etc/init.d/iptables restart

Leave a Reply