Shell命令sshpass非交互SSH密码验证

本文发布时间: 2019-Mar-22
Shell命令sshpass非交互SSH密码验证#安装sshpasssshpass下载地址:http://sourceforge.net/projects/sshpass/ 下载为一个 tar.gz的压缩包。$ tar -zxvf sshpass-1.05.tar.gz$ cd sshpass-1.05$ ./configure --prefix=/opt/sshpass #指定安装目录$ make$ make install$ cp /opt/sshpass/bin/sshpass /usr/bin/安装完成#查看帮助sshpass -hUsage: 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 informationAt most one of -f, -d, -p or -e should be used#!/bin/bashcd $(dirname $0)source ./config.shdate=`date +%Y-%m-%d`#上传DUMP脚本到服务端sshpass -pyour_pwd scp -P22 ./dump.sh [email protected]:~/#-o StrictHostKeyChecking=no 避免第一次登录出现公钥检查。sshpass -pyour_pwd scp -o StrictHostKeyChecking=no -P22 ./dump.sh [email protected]:~/#登陆到服务端地址,执行DUMP脚本,将执行结果写入本地文件sshpass -pyour_pwd ssh -p22 your_user @192.168.1.10 "sh ~/dump.sh" >local_result.txt#使用文件中的密码sshpass -f pwd.file ssh -p22 [email protected] "sh ~/dump.sh" >>local_result.txt#从环境变量(SSHPASS)读取密码sshpass -e ssh -p22 [email protected] "sh ~/dump.sh" >>local_result.txt


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:10pm
栏目列表