Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adds a user with key and home dir
#!/bin/bash
EXPECTED=1
if [ $# -ne $EXPECTED ]
then
echo "Please provide a username argument."
exit 5
fi
USER=$1
useradd $USER -m
mkdir /home/$USER/.ssh
# hard coded key or upload a file
#echo "< the pub key >" >> /home/$USER/.ssh/authorized_keys
cat /root/pub_key.tmp >> /home/$USER/.ssh/authorized_keys
chown -R $USER:$USER /home/$USER/.ssh
chmod 700 /home/$USER/.ssh
chmod 600 /home/$USER/.ssh/*
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.