解决Winscp连接 Ubuntu系统使用root拒绝访问

需要修改ssh配置文件:

1.vim /etc/ssh/sshd_config 修改该配置文件:

(使用root用户更改否则使用 sudo vim /etc/ssh/sshd_config)

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes

 PermitRootLogin without-password  修改为 PermitRootLogin yes

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

(或者将 PermitRootLogin without-password添加#注释掉,在下方新添加PermitRootLogin yes)如下:

更改PermitEmptyPasswords 为 no

修改完之后保存并退出

2.重启ssh服务

sudo service ssh restart   或者   /etc/init.d/ssh restart

 3. 重启服务器

sudo shutdown -r now

这样就可以成功登录了!!!

----------------------------------------------------------------------------------------------------------------------------

但是碰到过一次情况,就是修改之后还是无法登录,直接用root账号无法登陆远程终端,ubuntu 服务器默认的root账号是没有激活的,需要用初装的用户账号给root设置管理密码:

$ sudo passwd root  //用sudo修改root帐户

Password:  //输入密码
Enter new UNIX password:    //提示输入新的root帐户密码
Retype new UNIX password:   //再输入一次确认密码

修改成功之后你就可以使用root账号了,可以使用 su root 命令切换到root。然后就可以登录了。

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值