centos7设置ssh安全策略——只允许某个特定ip 访问

设置禁止所有ip连接服务器的SSH

vim /etc/hosts.deny

sshd:all:deny

设置允许指定ip连接服务器的SSH

vim /etc/hosts.allow

sshd:192.168.1.106:allow

重启SSH服务,并通过登录进行验证

systemctl restart sshd.service

systemctl status sshd.service

—————————————————————————————————————

如果需要更改端口,则是

vim /etc/ssh/sshd_config

修改端口,默认是22

Port 2222

禁止root账户通过SSH直接登录,默认是yes。(需要创建一个非root权限账号)

PermitRootLogin no

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注