Ubuntu 无法使用 root 用户进行 SSH 登录

转载自:https://liming.it/2017/02/06/ubuntu-cannot-ssh-connect-with-root-user/点击打开链接

我的系统是 Ubuntu 14.04.2 LTS,在配置 rsync 命令的时候,希望能将 root 用户开启,看了很多文章的介绍,通过 sudo passwd root 给 root 用户设置密码后就可以使用。
我参照提示配置了密码以后,用 SecureCRT 登录,却遇到了如下错误提示:Password authentication failed. Please verify that the username and password are correct.(密码验证失败,请确认用户名和密码都正确)

Ubuntu 无法使用 root 用户进行 SSH 登录_第1张图片
原来新版本里面 sshd_config 里面有了限制,解决办法如下:
1、使用 vi 打开文件 /etc/ssh/sshd_config,
sudo vi /etc/ssh/sshd_config

找到如下位置

# Authentication:
LoginGraceTime 120
#PermitRootLogin without-password    # 找到这里,把它注释,
PermitRootLogin yes                  # 添加这一行,设置为 yes
StrictModes yes

注意两点:
  • Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-59-generic x86_64) 上 PermitRootLogin without-password 变成了 PermitRootLogin prohibit-password
  • 如果 PasswordAuthentication 这一项是开启的,务必从 no 改成 yes
2、重启 ssh

service ssh restart
执行结果: 
ssh stop/waiting
ssh start/running, process 26317

注意:这里注意 /etc/init.d/ssh restart 用这个方式重启是不成功的,看不到任何结果
重启完成后再试试,非常完美

你可能感兴趣的:(Ubuntu 无法使用 root 用户进行 SSH 登录)