Created
May 15, 2016 07:18
-
-
Save birchestx/b0940e4d8a870699dc34c6eb59c18548 to your computer and use it in GitHub Desktop.
add user linux with root access, empty ssh key and permissions all set
This file contains 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 | |
if id "$1" >/dev/null 2>&1; then | |
echo "user exists" | |
else | |
echo "user does not exist, creating" | |
useradd -c "$1 last" $1 -m | |
fi | |
echo "$1 ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | |
su - $1 -c "mkdir .ssh" | |
su - $1 -c "chmod 700 .ssh" | |
su - $1 -c "touch .ssh/authorized_keys" | |
su - $1 -c "chmod 600 .ssh/authorized_keys" | |
su - $1 -c "chown -R $1:$1 .ssh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment