如何使用SFTP批处理文件发送密码 [英] How to send password using sftp batch file

查看:2805
本文介绍了如何使用SFTP批处理文件发送密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用批处理脚本SFTP站点下载文件。我得到了以下错误:

I'm trying to download a file from sftp site using batch script. I'm getting the following error:

Permission denied (publickey,password,keyboard-interactive).
Couldn't read packet: Connection reset by peer

在运行命令:

sftp -b /home/batchfile.sftp <user>@<server ip>:<folder>

batchfile.sftp 包括以下数据:

password
lcd [local folder]
cd [sftp server folder]
get *
bye

请注意:它的工作在提示符

Note: It's working when running at the prompt as

sftp <user>@<server ip>:<folder>

但我需要自动输入密码的能力。

But I need the ability to enter the password automatically.

推荐答案

您将要安装的sshpass程序。然后:

You'll want to install the sshpass program. Then:

sshpass -p YOUR_PASSWORD SFTP -oBatchMode =无-b YOUR_COMMAND_FILE_PATH USER @ HOST

显然,这是最好的设置公钥认证。仅使用此,如果这是不可能的事,无论出于何种原因。

Obviously, it's better to setup public key authentication. Only use this if that's impossible to do, for whatever reason.

这篇关于如何使用SFTP批处理文件发送密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆