Skip to content

Instantly share code, notes, and snippets.

@weaming
Last active August 17, 2021 01:22
Show Gist options
  • Save weaming/6988c473ad7e289b6d3a57f52070ccda to your computer and use it in GitHub Desktop.
Save weaming/6988c473ad7e289b6d3a57f52070ccda to your computer and use it in GitHub Desktop.
#!/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