Launch AWS AMI With Preconfigured Password
AWS will disable the preconfigured password that was previously configured when launching an instance from AMI. To keep the password active so that it can be login using username & password immediately upon launching it from image, lock_passwd needs to be set to false.
Let’s start from the beginning. Login EC2 with key.
Enable SSH login by password by editing the ssh config file
sudo vim /etc/ssh/sshd_config
Then set it to yes like below.
Set password for user ubuntu
sudo passwd ubuntu
Restart the SSH service.
sudo service ssh restart
Lastly disable AMI launch script that disable the password
sudo vim /etc/cloud/cloud.cfg
Set it to false like below.
Now create image
Launch new instance with the newly created image. Make sure you choose “Proceed without a key pair” when launching new instance.
Once the instance is started. SSH into the instance using username and password.