【环境】
OpenStack环境。
虚拟机使用的操作系统镜像中有一个非root用户,比如叫centos。
默认登录虚拟机的方式为密钥对
我使用的超级终端是Xshell。
1.执行以下命令,直接输入自己想要设置的root密码
#修改root密码
sudo passwd root
#切换到root用户
su - root
#修改sshd服务端配置文件,如下
vim /etc/ssh/sshd_config
PermitRootLogin=yes
PasswordAuthentication=yes
#重启sshd服务
systemctl restart sshd
确保/etc/ssh/sshd_config配置文件中PermitRootLogin及PasswordAuthentication的设置如下:
PermitRootLogin:是否允许root用户通过ssh方式远程登录
PasswordAuthentication:是否允许使用基于密码的认证
2.root用户通过ssh方式登录到虚拟机内