我正在尝试自动化文件传输或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,因此我无法执行下一步。
热心的帮助
发布于 2016-07-01 01:37:44
您需要在运行代码的客户端服务器上安装sshpass,该工具默认情况下不会安装在大多数Linux发行版上
如果您在Ubuntu中,请使用以下命令
apt-get install sshpass
在centOS/redhat上使用此安装epel
wget https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
安装sshpass
yum --enablerepo=epel -y安装sshpass
谢谢
发布于 2016-07-01 02:11:53
NO!不要安装sshpass。这对你的工作来说是错误的工具。
它不是为您的用例编写的,如果您使用它,您的脚本的安全性将大大低于它的安全性。我应该知道我在说什么。这是我写的。
相反,使用调试信息运行您的服务器,并找出无法设置基于密钥的身份验证的原因。它比以各种可能的方式使用sshpass更可取。
发布于 2019-12-30 18:53:03
我为CentOS 7得到的一个解决方案是:
从here下载
和rpm将会被下载。
DONE
https://stackoverflow.com/questions/38129835
复制相似问题