Launch AWS AMI With Preconfigured Password

Kevin FOO
2 min readAug 20, 2021

--

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.

lock_passwd: 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.

PasswordAuthentication yes

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.

lock_passwd: False

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.

< Back to all the stories I had written

--

--

Kevin FOO
Kevin FOO

Written by Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

No responses yet