1、使用gcp自带的浏览器shell登录vm实例
2、首先切换用户为root用户
sudo -i
3、为root用户设置密码
passwd root
输入两次root用户密码
Enter new UNIX password:
Retype new UNIX password:
控制台会提示设置成功
4、修改配置文件
vim /etc/ssh/sshd_config
需要修改的配置项目如下,在32行和56行:
PermitRootLogin yes
PasswordAuthentication yes
若使用centos则执行
vim /etc/ssh/sshd_config
输入vi 修改
PermitRootLogin yes
PasswordAuthentication yes
按esc 退出,输入:wq保存并退出vim
执行重启服务器的操作
reboot
即可生效,并且无需再执行/etc/init.d/ssh restart这个命令
5、重启服务
/etc/init.d/ssh restart
评论 (0)