1,MacOS 安装 sshpass
前置条件,先安装 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
保存进脚本:
#!/bin/bash
sshpass -p '1234' ssh hanmeimei@10.20.30.40
chmod u+x ssh10203040.sh
登陆:
./ssh10203040.sh
2,ubuntu 安装 sshpass
apt-cache search sshpass
sudo apt install sshpass
使用方式同1.