Skip to content

Instantly share code, notes, and snippets.

@digizeph
Created April 21, 2015 00:15
Show Gist options
  • Select an option

  • Save digizeph/f48326b8e2fb256ac863 to your computer and use it in GitHub Desktop.

Select an option

Save digizeph/f48326b8e2fb256ac863 to your computer and use it in GitHub Desktop.
Copy two columns from the Google Sheet, users and key. Then replace all the '\t' with '='. Name it as credentials.txt. Run this script. It should create the users for you.
#!/bin/bash
while IFS='=' read USER KEY
do
if [ ! -d "/home/$USER" ]; then
sudo useradd -m $USER -g snal
echo created user $USER
sudo su - $USER -c "mkdir /home/$USER/.ssh; echo $KEY > /home/$USER/.ssh/authorized_keys; chmod 600 /home/$USER/.ssh/authorized_keys"
else
echo $USER already created
fi
done < credentials.txt
@shaomeng

Copy link
Copy Markdown

Let me give it a try!

Thanks for sharing it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment