Prepare AMI for AWS Marketplace – Reset Linux ec2 Image – delete public keys, etc

When preparing a public AMI for AWS EC2, you need to delete lots of security stuff, like public keys, hosts and history.

sudo rm ~/.ssh/authorized_keys /home/ec2-user/.ssh/authorized_keys /root/.ssh/authorized_keys /root/.ssh/known_hosts ~/.ssh/known_hosts /home/ec2-user/.ssh/known_hosts

sudo shred -u /etc/ssh/*_key /etc/ssh/*_key.pub

sudo shred -u ~/.*history

Also see from our Blog:

Reset AWS AMI Windows 2016 and 2019 Password for use in Marketplace

Follow https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/building-shared-amis.html and this https://docs.aws.amazon.com/marketplace/latest/userguide/best-practices-for-building-your-amis.html

https://docs.aws.amazon.com/marketplace/latest/userguide/product-and-ami-policies.html

Hits: 29