Skip to content

Instantly share code, notes, and snippets.

@armanm
Created April 16, 2013 06:08
Show Gist options
  • Save armanm/5393730 to your computer and use it in GitHub Desktop.
Save armanm/5393730 to your computer and use it in GitHub Desktop.
This shell script lets you check who can login to your server using SSH keys
#!/bin/sh
#
# check who can login to a user's account
#
check_user()
{
local IFS=:
while read user home; do
test -e $home/.ssh/authorized_keys || continue
cut -d' ' -f3 $home/.ssh/authorized_keys | sed -e "s/^/user $user: /"
done
}
cut -d: -f1,6 /etc/passwd | check_user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment