sshpass

最後更新: 2016-03-15

 

介紹

sshpass 應用在 non-interactive mode 時的 ssh

它用來應付 "keyboard-interactive" password authentication

sshpass runs ssh in a dedicated tty

 


Install

 

# EPEL

yum install sshpass

 


Usage

 

cli:

sshpass [options] command arguments

opt:

-ffilename              # The password is the first line of the file filename

-ppassword            # The password is given on the command line.

-e                          # environment variable "SSHPASS"

 * 用 sshpass 前一定要 ssh 對方一次, 接受對方的 "RSA key fingerprint" 先

e.g.

# remote cmd

sshpass -f pw.txt ssh 192.168.88.128 uptime

# rsync

rsync --rsh='sshpass -p 12345 ssh -l test' host.example.com:path .

OR

SSHPASS=12345 rsync --rsh='sshpass -e ssh -l test' host.example.com:path .

 


 

Creative Commons license icon Creative Commons license icon