ubuntu root账号无法用ssh登录

Ubuntu默认情况下root账号无法用ssh登录,需要修改认证信息即可。

1、进行编辑: vi /etc/ssh/sshd_config
2、找到PermitRootLogin添加一行PermitRootLogin yes,如下:

#Authentication:

#LoginGraceTime 2m

#PermitRootLogin prohibit-password

#PermitRootLogin yes

#StrictModes yes#MaxAuthTries 6

#MaxSessions 10

保存退出后,重启ssh服务,输入命令:etc/init.d/ssh restart 即可。

Linux系统限制SSH ip访问

1、vi /etc/hosts.allow <允许访问的主机>
sshd:XXX.XXX.XXX.XXX:allow <单个主机>
sshd:XXX.XXX.XXX.*:allow <允许1个网段主机>

2、vi /etc/hosts.deny <黑名单>
sshd:xxx.xxx.xxx.xxx:deny <禁止单个主机访问>
sshd:ALL <禁止所有主机访问>

3、systemctl restart sshd <重新启动SSH 服务>