zhmg23

我们是如此的不同

sshpass解决ssh、scp等交互输入密码

1、下载安装sshpass地址

RHEL6:  wget  ftp://fr2.rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/sshpass-1.05-1.el6.rf.x86_64.rpm

RHEL7:  wget  ftp://fr2.rpmfind.net/linux/dag/redhat/el7/en/x86_64/dag/RPMS/sshpass-1.05-1.el7.rf.x86_64.rpm

2、sshpass使用帮助

# sshpass --help

sshpass: invalid option -- '-'

Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters

   -f filename   Take password to use from file

   -d number     Use number as file descriptor for getting password

   -p password   Provide password as argument (security unwise)

   -e            Password is passed as env-var "SSHPASS"

   With no parameters - password will be taken from stdin

   -h            Show help (this screen)

   -V            Print version information

At most one of -f, -d, -p or -e should be used


3、案例

远程scp拷贝文件不用在交互输入密码

# sshpass -p '123456' scp -r testssh@192.168.1.12:/data/t.war    /data/

评论

热度(1)