1、根据官网提供的方法登录连接到EC2服务器
2、 创建root的密码,输入如下命令:
sudo passwd root
3、然后会提示你输入new password。输入一个你要设置的root的密码,需要你再输入一遍进行验证。
4、接下来,切换到root身份,输入如下命令:
su root
5、使用root身份编辑亚马逊云主机的ssh登录方式,找到 PasswordAuthentication no,把no改成yes。输入:
vim /etc/ssh/sshd_config
6、接下来,要重新启动下sshd,如下命令:
sudo /sbin/service sshd restart
7、然后再切换到root身份
su root
8、再为原来的”ubuntu”添加登录密码。如下命令:
passwd ubuntu
按提示,两次输入密码。到此可以用root身份直接登录EC2的服务器了。
9、修改sshd配置文件
vi /etc/ssh/sshd_config
PermitRootLogin这行改为PermitRootLogin yes//设定是否允许root管理员直接登录
PasswordAuthentication no改为PasswordAuthentication yes//开启密码验证
UsePAM yes改为UsePAM no//这个待测
// 重启 sshd 服务
systemctl restart sshd
// 将 sshd 服务加入到开机启动项中
systemctl enable sshd