centos 7限制远程登录的端口、IP、用户

限制端口

在/etc/ssh/sshd_config中

限制IP

要求: 只允许 192.168.0.1 和 192.168.0.10 登陆 其他全部禁止

实现:

  1. vim /etc/hosts.allow //增加如下内容
    sshd: 192.168.0.1:allow  , 192.168.0.10:allow  

  2. vim /etc/hosts.deny //增加如下内容
    sshd: ALL

要求: 只限制192.168.0.1登陆不上来,其他全部放行

实现:
vim /etc/hosts.deny //增加如下内容
sshd: 192.168.0.1

禁止root用户登录

需要编辑/etc/ssh/sshd_config。

vim /etc/ssh/sshd_config    找到 PermitRootLogin

改为 PermitRootLogin no

重启  service sshd restart

猜你喜欢

转载自blog.csdn.net/qq_38279833/article/details/106489886