Skip to content

Instantly share code, notes, and snippets.

@nl5887
Last active January 26, 2017 01:40
Show Gist options
  • Select an option

  • Save nl5887/aa62810158e2003b4be80b6cfbcd0fdf to your computer and use it in GitHub Desktop.

Select an option

Save nl5887/aa62810158e2003b4be80b6cfbcd0fdf to your computer and use it in GitHub Desktop.
#!/bin/bash
# use with caution all user accounts that have
# a github account and exists on the system
# will be able to logon to this system
# make sure you have curl and jq installed
user=$1
for u in "root" "ubuntu" "ec2-user" "nobody"; do
if [ "$user" == "$u" ]; then
# root not allowed, to prevent single users to login to several
echo -e "# $user not allowed"
exit
fi
done
if [ $(id -u $user 2>/dev/null || echo "0") -lt 1000 ]; then
echo -e "# user id not allowed"
exit
fi
output=$(curl -s "https://api.github.com/users/$user/keys")
echo "$output" | jq -r '.[] | .key'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment