• 人生,不能用时间去衡量

教你在AWS EC2、Lightsail / Google Compute 等vps开启 root 登录权限

VPS 刚刚 2046次浏览 1个评论

Amazon AWS EC2 / Lightsail、Google Compute 等主机,安装 Linux 系统默认是禁止 root 登录的,要使用 root 权限,需要在执行命令时加个 sudo,或者通过命令 sudo -i 进入 root 用户模式,或多或少有些不便,这时我们就考虑是否可以开启 root 直接登录呢?

注意:

将下面代码中的第一句中的 pass 改为自己将要设置的密码,否则默认 root 密码为 pass。

用法:

先用其他用户名登陆进 ssh,再将下列代码复制进去(注意更改root密码)。

echo root:pass |sudo chpasswd root 
sudo sed -i 's/^.*PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config; 
sudo sed -i 's/^.*PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
sudo service sshd restart

以上代码在 Debian / Ubuntu/Centos7 上通过测试,其他发行版自行测试
喜欢 (3)
[]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(1)个小伙伴在吐槽
  1. 感谢,看到你这才解决,其他都浪费时间
    xsfen2023-05-13 04:47 回复