Last active
October 20, 2018 18:44
-
-
Save benharri/98835365837a9acc9e04479b9183a799 to your computer and use it in GitHub Desktop.
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 | |
ssh tilde.team "awk -F: '($3>=500) && ($3!=65534)' /etc/passwd" > /tmp/passwd.new | |
ssh tilde.team "awk -F: '($3==100) && ($3!=65534)' /etc/group" > /tmp/group.new | |
ssh tilde.team "awk -F: '($3>=500) && ($3!=65534)' /etc/passwd | grep -f - /etc/shadow" > /tmp/shadow.new | |
cat /tmp/passwd.new | awk -F : '{printf("%s:%s:%s:%s::0:0:%s:%s:%s\n", $1,$2,$3,$4,$5,$6,$7); }' > /tmp/masterpasswd.new | |
cat /tmp/passwd.new >> /etc/passwd && sort -u /etc/passwd > /etc/passwd | |
cat /tmp/group.new >> /etc/group && sort -u /etc/group > /etc/group | |
cat /tmp/shadow.new >> /etc/shadow && sort -u /etc/shadow > /etc/shadow | |
cat /tmp/masterpasswd.new >> /etc/master.passwd && sort -u /etc/master.passwd > /etc/master.passwd | |
pwd_mkdb -p /etc/master.passwd | |
grep 100 /etc/passwd | cut -d : -f 1 | xargs -I "{}" mkdir -p /home/{}/.ssh | |
grep 100 /etc/passwd | cut -d : -f 1 | xargs -I "{}" scp -p tilde.team:/home/{}/.ssh/authorized_keys | |
grep 100 /etc/passwd | cut -d : -f 1 | xargs -I "{}" chown -R {}:team /home/{} | |
grep 100 /etc/passwd | cut -d : -f 1 | xargs -I "{}" chmod 644 /home/{}/.ssh/authorized_keys | |
You have new mail in /var/mail/root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment