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.(密码验证失败,请确认用户名和密码都正确)


原来新版本里面 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 用这个方式重启是不成功的,看不到任何结果
重启完成后再试试,非常完美
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值