Created
January 12, 2019 01:25
-
-
Save benharri/b5a8e8da05c5204b0d4cc74a07a9b7af to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
ssh tilde.team -- unshadow /etc/passwd /etc/shadow \ | |
| awk -F : '{printf("%s:%s:%s:%s::0:0:%s:%s:%s\n", $1,$2,$3,$4,$5,$6,$7); }' > new_passwd | |
last_user=$(tail -n1 /etc/passwd | cut -f1 -d:) | |
sed -i "" "1,/^${last_user}/d" new_passwd | |
if [[ $(wc -l < new_passwd) -lt 1 ]]; then | |
echo no new users | |
exit 1 | |
fi | |
cat new_passwd >> /etc/master.passwd | |
pwd_mkdb -p /etc/master.passwd | |
for user in $(cut -d: -f1 < new_passwd); do | |
echo -n "${user}: " | |
mkdir -m 700 -p /home/$user/.ssh | |
scp tilde.team:/home/$user/.ssh/authorized_keys /home/$user/.ssh/authorized_keys | |
chmod 600 /home/$user/.ssh/authorized_keys | |
chown -R $user:team /home/$user | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment