利用sshpass 幫你輸入ssh 密碼
1:sshpass下载与安装 (redhat 5.5 )
yum安装:
yum install sshpass
若yum安装不上,则用下面方法 2:下载后,解压,安装 (vmware 使用 share_file ,then cp to /home/a202/)
tar -zxvf sshpass-1.06.tar.gz
cd sshpass-1.06
./configure
make
make install 3:使用命令
sshpass -p 123456 sftp user@F55C
F55C NEED TO PUT ON /ETC/HOSTS 10.10.10.10 F55C
4:脚本
#!/bin/bash
password=123456
user=user
ip=10.10.10.2
#file=/mis/komin/RC00573368.txt file=/home/mis/kmsrc/psmp1030.4gl sshpass -p $password sftp $user@$ip lcd kmsrc cd /D:/komin put $file bye 5. Transfer filesshpass -e sftp -oBatchMode=no -b - sftp-user@remote-host << ! cd /data put your-file.log bye!
|