Created
June 11, 2019 08:36
-
-
Save dot/12d7d814e92ee30b879d7f0df862b935 to your computer and use it in GitHub Desktop.
ssh auth
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/sh | |
set -e | |
userHome=$(getent passwd $(whoami) | cut -d":" -f6) | |
cacheFile="$userHome""/.ssh/authorized_keys_cache" | |
cacheValidity="300" | |
if [ ! -f "$cacheFile" ] || [ "$(($(date +%s) - $(stat -c %Y "$cacheFile")))" -gt "$cacheValidity" ] | |
then | |
rm -f $cacheFile | |
users=$(aws s3 cp s3://s3-backet/authorized/users -) | |
for u in $users | |
do | |
wget --quiet https://github.com/$u.keys -O - >> $cacheFile | |
done | |
fi | |
cat "$cacheFile" |
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
# add this lines | |
AuthorizedKeysCommand /usr/local/bin/auth_gh.sh | |
AuthorizedKeysCommandUser ec2-user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment