Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Standup an EC2 instance without keys using the CloudFormation

How do I create a CloudFormation stack that automatically stands-up an EC2 linux instance but the login to be made via a password and without any keys.

I found a tutorial to enable password authentication but It requires changing the data in sshd_config and restarting the instance and I’m not sure how to replicate that in an cloudformation stack.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I suggested by Mr. Paolo user-data is the way to go.

Your final user-data script will look like this:

#!/bin/bash
yum update -y
yum install -y httpd
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
systemctl restart sshd

This will make sure password auth is enabled once your system boots up and performs user data operations.

Learn more about user data over this link:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html

Hope this helps. Thanks.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading