I want to speed up creation of user accounts on some Linux VMs that I am creating, and wondered if I could simplify the process of writing to the new user's
My manual process is, approximately (logged in as the new user):
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa touch ~/.ssh/authorized_keys chmod go-rwx ~/.ssh/authorized_keys echo '... me@machine' >> ~/.ssh/authorized_keys
Is there any way, with a Bash command, a standard GNU command, or any program easily installed on Ubuntu, to condense the
echo into one command?
Part of the reason I would like to reduce it to one command is so that I can make a shell script that I can run as the initial sudo-capable user on the VM.
sudo su - me -c 'ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa' echo '... me@machine' | sudo su - me -c 'xyz 0600 ~/.ssh/authorized_keys'
xyz is the hypothetical command that creates, sets permissions, and writes the file all in one fell swoop.