一般安装的Ubuntu 系统默认的不设置 root 帐户和密码,这是为了安全做考虑。但是如果是本地虚拟机或者是作为测试使用,直接使用root账户登录能减少很多麻烦。
1. 使用账号登录Ubuntu系统
2. 执行命令设置root密码
sudo passwd root
3. 执行以下命令,打开 sshd_config
配置文件
vi /etc/ssh/sshd_config
找到 #Authentication,将 PermitRootLogin 参数修改为 yes
将 PasswordAuthentication 参数修改为 yes


4. 重启 ssh 服务即可使用root账户登录
service ssh restart