Last active
August 17, 2021 01:22
-
-
Save weaming/6988c473ad7e289b6d3a57f52070ccda to your computer and use it in GitHub Desktop.
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 | |
# macos: brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb | |
user=$1 | |
ip_or_tail=$2 | |
if echo $ip_or_tail | grep -E '\.' >/dev/null; then | |
user_host=$user@$ip_or_tail | |
else | |
[email protected].$ip_or_tail | |
fi | |
echo $user_host | |
passwd=$(cat ~/.ssh/passwords | grep "$user_host" | awk '{print $2}') | |
if [ -z "$passwd" ]; then | |
echo missing password in file ~/.ssh/passwords: | |
cat ~/.ssh/passwords | |
exit 1 | |
fi | |
shift | |
shift | |
sshpass -p $passwd ssh -oStrictHostKeyChecking=no $user_host $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment