Skip to content
Advertisement

correct way to rename user and remove password with ec2 user-data

I have a centos7 base ami and have successfully changed the user name using the ec2-launch user data modified from an amazon-linux script

JavaScript

log in works as expected and home directory has been changed, however when I use sudo it still asks for a password. As I cannot get into the file to check format I wonder if I am using the correct syntax?

How do change the user and remove the sudo password requirement in a single script?

Advertisement

Answer

I believe your Cloudinit userdata script is failing because it’s attempting to use sudo without a tty (and the !requiretty hasn’t been added yet). Since that script runs as root anyways, this should work:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement