前置条件,先安装 brew:
$ xcode-select --install
$ curl -O https://raw.githubusercontent.com/Homebrew/install/master/install.sh
$ chmod +x install.sh
$ ./install.sh
安装 sshpass:
$ brew search sshpass
$ brew install sshpass
验证:
使用
sshpass -p '1234' ssh hanmeimei@10.20.30.40
保存进脚本:
ssh10203040.sh
#!/bin/bash
sshpass -p '1234' ssh hanmeimei@10.20.30.40
chmod u+x ssh10203040.sh
登陆:
./ssh10203040.sh