Sshpass using SSH so-called "interactive keyboard password authentication" tools to perform password authentication in a non-interactive mode
Popular, is to use ssh password is required when connecting to type your password , no way explicitly connected, as shown, a password is required to interact.
The Sshpass to do is to use ssh by clear text, and brought some more fresh features
installation
macOS - brew to download and install
# 安装命令 brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb # 连接到/usr/local/bin (如果提示 command not found) cd /usr/local/bin ln -s sshpass ../Cellar/sshpass/1.06/bin/sshpass
Debian -
apt install sshpass
CentOS -
yum install sshpass
Source Installation
$ wget http://sourceforge.net/projects/sshpass/files/latest/download -O sshpass.tar.gz $ tar -xvf sshpass.tar.gz $ cd sshpass-1.06 $ ./configure # sudo make install
use
# 简单使用,使用密码 XXX 连接Ip的默认ssh
sshpass -p "XXX" ssh user@IP
advanced
Ssh remote connection to the specified port
sshpass -p {密码} ssh -p ${端口} {用户名}@{主机IP}
Read the contents of the file as the password from the password file to a remote host connection
sshpass -f ${密码文本文件} ssh {用户名}@{主机IP}
Pull files from a remote host to local
sshpass -p {密码} scp {用户名}@{主机IP}:${远程主机目录} ${本地主机目录}
The host directory files are copied to the remote host directory
sshpass -p {密码} scp ${本地主机目录} {用户名}@{主机IP}:${远程主机目录}
Remote connection to the host and execute commands
sshpass -p {密码} ssh -o StrictHostKeyChecking=no {用户名}@{主机IP} 'rm -rf /tmp/test'
-o StrictHostKeyChecking = no: Ignore the password prompt
More
More excellent tool, please focus on micro-channel public number acquisition
This article from the blog article multiple platforms OpenWrite release!