Last active
October 1, 2018 03:32
-
-
Save deviousway/e4100a67882d5dbbfbe6ea5d65ef644e to your computer and use it in GitHub Desktop.
linux copy/migrate users from one server to another
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
mkdir move/ | |
export UGIDLIMIT=500 | |
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig | |
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig | |
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/move/shadow.mig | |
cp /etc/gshadow /root/move/gshadow.mig | |
scp -r /root/move/* user@new.linuxserver.com:/path/to/location | |
mkdir /root/newsusers.bak | |
cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak | |
cat passwd.mig >> /etc/passwd | |
cat group.mig >> /etc/group | |
cat shadow.mig >> /etc/shadow | |
cp gshadow.mig /etc/gshadow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment