Created
June 6, 2014 02:16
-
-
Save allex/56a01fed5bdbd5cd5ced 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 | |
# add trust to which user? | |
user=$1 | |
# user home | |
home=$(grep -E "^${user}:" /etc/passwd|cut -d: -f6) | |
# base dir | |
base=$2 | |
cd $base | |
if [ "X${home}" != 'X' ];then | |
# fix perms | |
mkdir -p ${home}/.ssh && \ | |
touch ${home}/.ssh/authorized_keys && \ | |
chown -R ${user}:${user} ${home}/.ssh && \ | |
chmod 700 ${home}/.ssh && \ | |
echo "Fix Complete" | |
#modify authorized_key | |
cat ${home}/.ssh/authorized_keys $base/keys/* |sort -u >$base/authorized_keys && \ | |
diff ${home}/.ssh/authorized_keys $base/authorized_keys | |
mv $base/authorized_keys ${home}/.ssh/authorized_keys && \ | |
chmod 600 ${home}/.ssh/authorized_keys && \ | |
echo "Add Complete!" | |
#rm -rf $base && echo "Clean Complete" | |
else | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment