吴伟贤のBlog

Feed Rss

ssh限制登录IP修改端口

08.04.2010, linux, by .

在/etc/hosts.allow输入 
  (其中192.168.10.88是你要允许登陆ssh的ip,或者是一个网段192.168.10.0/24) 
  sshd:192.168.10.88:allow 
  在/etc/hosts.deny输入(表示除了上面允许的,其他的ip   都拒绝登陆ssh) 
  sshd:ALL
vi /etc/ssh/sshd_config

比如说你只允许1.1.1.1这个IP进入,其它都禁止:
方法1、iptables。
iptables   -A   INPUT   -s   1.1.1.1   –destination-port   22   -j   ACCEPT
iptables   -A   INPUT   –destination   22   -j   DROP
方法2:
vi   /etc/ssh/sshd_config
添加一行:
allowusers   xxx@1.1.1.1
注:xxx为你用来登入服务器的用户名。

评论已关闭。