Created
April 21, 2015 00:15
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let me give it a try!
Thanks for sharing it ;)