腾讯云服务器Ubuntu系统如何使用 root 用户远程登录

问题描述:

腾讯云服务器Ubuntu 系统的默认用户名是 ubuntu,并且在安装过程中默认不设置 root 帐户和密码。如果想直接以root用户进行远程登录,可在设置中开启允许 root 用户登录。具体操作步骤如下:

解决方案:

1. 使用 ubuntu 帐户登录轻量应用服务器。

2. 设置root用户的登录密码

sudo passwd root

3. 输入 root 的密码,按 Enter。

4. 重复输入 root 的密码,按 Enter。

如果提示以下消息,即表示 root 密码设置成功。
passwd: password updated successfully

5. 执行以下命令,打开 sshd_config 配置文件。

sudo vi /etc/ssh/sshd_config 

6. 找到 #Authentication,按 i 切换至编辑模式,将 PermitRootLogin 参数修改为 yes。

注意 : 如果 PermitRootLogin 参数被注释,请去掉首行的注释符号(#)。如下图所示:

#Authentication :
#LoginGraceTime 2m
permitRootLogin yes
#strictModes yes
#MaxAuthTries 6
#Maxsessions 10
#PubkeyAuthentication yes

7. 找到 # Authentication,将 PasswordAuthentication 参数修改为 yes。

可能 # Authentication中没有 PasswordAuthentication,如果你和我一样的话那就在末尾添加上这个键值

#Example of overriding settings on a per-user basis
#Match User anoncvs
#          x11Forwarding no
#          AllowTcpForwarding no
#          PermitTTY no
#          ForceCommand cvs server
PasswordAuthentication yes

8.按 Esc,输入 :wq,保存文件并返回。

9. 执行以下命令,重启 ssh 服务。

sudo service ssh restart

至此配置结束了,然后就可以用root远程登录 Ubuntu 轻量应用服务器了

  • 6
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值