为什么 ssh myLogin@localhost 可以工作,但 ssh root@localhost 不行?

为什么 ssh myLogin@localhost 可以工作,但 ssh root@localhost 不行?

我知道 ssh root@localhost 是一个坏主意......我明白了。

但为什么不起作用呢ssh root@localhost

我什至更改了 root 密码以防万一:

> sudo -s
> passwd

但当我这样做时ssh root@localhost我仍然得到

root@localhost's password:[我输入密码]

Permission denied, please try again.


我尝试了 ssh -v 不知道要寻找什么,这里是最后几行:

...
debug1: Offering RSA public key: /home/myName/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/myName/.ssh/id_dsa
debug1: Trying private key: /home/myName/.ssh/id_abcde
debug1: Trying private key: /home/myName/.ssh/id_ed123456
debug1: Next authentication method: password
root@localhost's password: 
debug1: Authentications that can continue: publickey,password                                                                                                                                     
Permission denied, please try again.                                                                                                                                                              
root@localhost's password:                                                                                                                                                                        
debug1: Authentications that can continue: publickey,password                                                                                                                                     
Permission denied, please try again.                                                                                                                                                              
root@localhost's password:                                                                                                                                                                        
debug1: Authentications that can continue: publickey,password                                                                                                                                     
debug1: No more authentication methods to try.                                                                                                                                                    
Permission denied (publickey,password). 

/etc/ssh/sshd_config

ChallengeResponseAuthentication no
PermitRootLogin without-password

答案1

问题是这一行:

PermitRootLogin without-password

根据 sshd_config手册页:

允许root登录
指定 root 是否可以使用 ssh(1) 登录。参数必须是“yes”、“without-password”、“forced-commands-only”或“no”。默认为“是”。

如果该选项设置为“无密码”,则采用密码验证残疾人为根。

without-password设置主要用于使用公钥登录(在 中~/.ssh/authorized_keys)。

相关内容