#!/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 user_host=$user@192.168.1.$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 $@