1.利用 cloud-init脚本来开启root账号密码登录
#!/bin/bash
echo root:11235879 |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默认密码是: 11235879
登录后一定要修改密码!命令: passwd
2.使用密钥登录系统以后,执行如下命令
sudo -i
passwd按提示刷入密码,重复输入密码。 接着输入
echo root:11235879 |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;
service sshd restart3、使用密钥登录系统以后
sudo -i
vi /root/.ssh/authorized_keys把ssh-rsa之前的内容都删除掉.
vi /etc/ssh/sshd_config找到PermitRootLogin, 把前面的#去掉
更改为 PermitRootLogin yes 找到 PasswordAuthentication 更改为 PasswordAuthentication yes 退出编辑 passwd 更改密码 reboot 重启vps
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。




























































