【发布时间】:2016-11-02 22:42:46
【问题描述】:
我正在尝试自动执行从一台服务器到另一台服务器的文件传输或 FTP。
#!/bin/bash
### In this model, the same filename is processed on each run.
### A timestamp is added to the result file and data file is copied to the archive or error folder with a timestamp after processing.
# Set current directory
cd `dirname "$0"`
# Set the environment variables
. ./Environment.sh $0
#######################################################################################################
#
#######################################################################################################
FILE=/hcm/Inbound/file.csv
sshpass -p 'xyz' sftp -oBatchMode=no -b - -oStrictHostKeyChecking=no zys@192.abc.taleo.net <<_EOF_
cd /upload/
put $FILE
_EOF_
# Exit
exit $?
当我执行这个 shell 脚本时,我在 putty 中收到以下错误:
-bash: sshpass: command not found
我尝试通过ssh-keygen -t dsa 和其他步骤使用ssh 无密码方法,但我无法访问第二台服务器的腻子,因此无法执行后续步骤。
请帮忙
【问题讨论】:
-
“无法访问第二台服务器的putty”?赦免?您可以通过多个跃点使用无密码 SSH,方法是将您的密钥加载到代理中(顺便说一句,RSA 密钥优于 DSA)并启用代理转发;您实际上不需要在退回主机上提供私钥。
-
顺便说一句,
exit $?是完全多余的:exit默认通过前一个命令的退出状态。此外,您在这里遗漏了一些引文——shellcheck.net 会识别出来。
标签: linux shell unix ssh sshpass