Ubuntu 系统的默认用户名是 ubuntu,并在安装过程中默认不设置 root 帐户和密码。
其实之前文章中有过介绍,不过在实际使用中发现跟在甲骨文中有些不一样,重新记录一下。
步骤
-
使用 ubuntu 账号登录服务器。
-
执行以下命令,设置 root 密码:
sudopasswd root -
输入 root 的密码,按 Enter。
-
重复输入 root 的密码,按 Enter。返回如下信息,即表示 root 密码设置成功。
passwd: password updated successfully -
执行以下命令,打开
sshd_config配置文件。
sudo vi /etc/ssh/sshd_config
- 按 i 切换至编辑模式,找到
#Authentication,将PermitRootLogin参数修改为yes。如果PermitRootLogin参数被注释,请去掉首行的注释符号(#)。 - 找到
#Authentication,将PasswordAuthentication参数修改为yes。
若sshd_config配置文件中无此配置项,则添加PasswordAuthentication yes项即可。 - 按 Esc,输入
:wq,保存文件并返回。 - 执行以下命令,重启 ssh 服务。
sudo service ssh restart
- 使用用户名
root及设置的密码登录服务器。
Ubuntu 系统如何使用 root 用户登录
https://wuqishi.com/archives/how-to-use-root-login-for-ubuntu-systems
评论