备忘,安装并使用 sshpass -p ‘654321‘ ssh hanmeimei@10.20.30.40-1,MacOS 安装 sshpass

时间:2024-10-14 08:11:34

前置条件,先安装 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