Skip to content

Instantly share code, notes, and snippets.

@dot
Created June 11, 2019 08:36
Show Gist options
  • Save dot/12d7d814e92ee30b879d7f0df862b935 to your computer and use it in GitHub Desktop.
Save dot/12d7d814e92ee30b879d7f0df862b935 to your computer and use it in GitHub Desktop.
ssh auth
#!/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"
# 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