Skip to content

Instantly share code, notes, and snippets.

@himynameschris
Created July 25, 2015 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save himynameschris/9431e8891748fa76a1a8 to your computer and use it in GitHub Desktop.
Save himynameschris/9431e8891748fa76a1a8 to your computer and use it in GitHub Desktop.
Check if Linux user exists then test ssh login
#!/bin/sh
while read u; do
echo "checking for username: "$u
getent passwd $u > /dev/null
if [ $? -eq 0 ]; then
id $u
status=$(ssh -o BatchMode=yes -o ConnectTimeout=5 $u@127.0.0.1 -p 22 echo ok 2>&1)
echo $status
fi
done <usernames.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment