sshpass 的使用
ssh远程连接时,每次都提示需要输入密码。需要ssh到多台机器时很不方便。sshpass可以解决这个问题。sshpass可以实现ssh的自动的登录。直接在命令里输入密码,但是安全性的问题需要自己判断。
安装
Installing on Ubuntu
apt-get install sshpass
Installing on OS X
开始之前需要安装
install xcode and command line tools.
之后安装Installing with Homebrew
由于安全问题,brew 官方默认不允许安装,可以尝试如下方法:
brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb
源码安装
- Download the Source Code
- Extract it and cd into the directory
./configure
sudo make install
用法介绍
1 | [[email protected] ~]# sshpass --help |
1 | -p password #后跟密码 |
如果在多台主机执行命令:
1 | [[email protected] ~]# cat a.sh |