EC2免pem用密碼登陸

原理

EC2在初始化實例時,會運行cloud-init腳本一次。

我們可以在cloud-init腳本中修改登陸的安全設置PasswordAuthentication

默認PasswordAuthentication是no

操作

在設置實例信息時,打開“高級詳細信息

填入如下信息

#cloud-config
password: 《你要設置的登陸密碼》
chpasswd: { expire: False }
ssh_pwauth: True

如圖



登陸

在系統初始化完之後,可以直接使用

ssh ec2-user@你的實例的ip地址
就能登陸了。

中間會提示輸入登陸密碼

The authenticity of host 'ec2-xxx-xx-xxx-xxx.compute-1.amazonaws.com (xx.xx.x.xx<span style="font-family: Arial, Helvetica, sans-serif;">)' can't be established.</span>
RSA key fingerprint is .
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-xxx-xx-xxx-xxx.compute-1.amazonaws.com,xx.xx.x.xx' (RSA) to the list of known hosts.
[email protected]'s password: 

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2015.03-release-notes/
No packages needed for security; 1 packages available
Run "sudo yum update" to apply all updates.



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章