Created
July 26, 2019 11:13
-
-
Save Zejnilovic/85253773e965d5850350170421e49000 to your computer and use it in GitHub Desktop.
Connect to one of the servers
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/bash | |
# Switch this for the list of addresses you want to ssh to | |
ADDRESS=(127.0.0.1 localhost) | |
# Switch this for the name of the user you are sshing as | |
NAME=`echo $USER` | |
for i in $ADDRESS | |
do | |
echo "Trying to connect as $NAME to $i" | |
if ssh $NAME@$i 2> /dev/null; [ $? -eq 0 ]; then | |
exit 0 | |
fi | |
echo "Unable to ssh to $i" | |
done | |
echo "" | |
echo "Ssh Failed" | |
exit 255 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment