AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1171900
Accepted
tb1
tb1
Asked: 2025-01-30 06:50:28 +0800 CST2025-01-30 06:50:28 +0800 CST 2025-01-30 06:50:28 +0800 CST

psftp -b 参数失败:致命:无法打开

  • 772

[从 StackOverflow 移出]

我们使用 PSFTP 以及 ppk 文件和批处理命令文件将 CSV 上传到远程 SFTP 主机。这已经运行了很多个月,直到最近 -b 参数才失败,并显示“严重:无法打开”

详细信息:
我们使用批处理文件或命令提示符在 Windows 上运行 PSFTP.exe。

我们通过 -b 参数传递的批处理命令文件名为“sftpcommands.txt”,包含以下几行:

put "D:\batch\Upload.csv"
quit

以下是我们从批处理文件或命令提示符运行的内容:

psftp.exe -v -P 22 -i D:\batch\keyfile.ppk -b D:\batch\sftpcommands.txt [email protected]

结果如下:

Looking up host "SFTPHost.domain.com" for SSH connection
Connecting to hostIP port 22
We claim version: SSH-2.0-PuTTY_Release_0.82
Connected to hostIP (from localIP:35022)
Remote version: SSH-2.0-AWS_SFTP_1.1
Using SSH protocol version 2
No GSSAPI security context available
Doing ECDH key exchange with curve nistp256, using hash SHA-256 (SHA-NI accelerated)
Host key fingerprint is:
ssh-rsa 4096 SHA256:ajIF+morestuffhere
Initialised AES-256 SDCTR (AES-NI accelerated) outbound encryption
Initialised HMAC-SHA-256 (SHA-NI accelerated) outbound MAC algorithm
Initialised AES-256 SDCTR (AES-NI accelerated) inbound encryption
Initialised HMAC-SHA-256 (SHA-NI accelerated) inbound MAC algorithm
Reading key file "D:\batch\keyfile.ppk"
Using username "OurUser".
Offered public key
Offer of public key accepted
Authenticating with public key "keynameinformation here"
Sent public key signature
Access granted
Opening main session channel
Remote debug message: SFTP: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
Remote debug message: SFTP: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
Opened main channel
Started a shell/command
Connected to some-host.server.transfer.us-east-1.amazonaws.com
Remote working directory is /
Fatal: unable to open
Session sent command exit status 0
Main session channel closed
All channels closed

现在奇怪的部分是:我们可以摆脱 -b 脚本语法,并sftpcommands.txt在提示符出现时手动输入在文件中找到的相同命令psftp>(例如):

psftp.exe -v -P 22 -i D:\batch\keyfile.ppk [email protected]

Looking up host "SFTPHost.domain.com" for SSH connection
Connecting to hostIP port 22
We claim version: SSH-2.0-PuTTY_Release_0.82
Connected to hostIP (from localIP:35022)
Remote version: SSH-2.0-AWS_SFTP_1.1
Using SSH protocol version 2
No GSSAPI security context available
Doing ECDH key exchange with curve nistp256, using hash SHA-256 (SHA-NI accelerated)
Host key fingerprint is:
ssh-rsa 4096 SHA256:ajIF+morestuffhere
Initialised AES-256 SDCTR (AES-NI accelerated) outbound encryption
Initialised HMAC-SHA-256 (SHA-NI accelerated) outbound MAC algorithm
Initialised AES-256 SDCTR (AES-NI accelerated) inbound encryption
Initialised HMAC-SHA-256 (SHA-NI accelerated) inbound MAC algorithm
Reading key file "D:\batch\keyfile.ppk"
Using username "OurUser".
Offered public key
Offer of public key accepted
Authenticating with public key "keynameinformation here"
Sent public key signature
Access granted
Opening main session channel
Remote debug message: SFTP: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
Remote debug message: SFTP: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
Opened main channel
Started a shell/command
Connected to some-host.server.transfer.us-east-1.amazonaws.com
Remote working directory is /
psftp> put "D:\batch\Upload.csv"
local:D:\batch\Upload.csv => remote:/Upload.csv
psftp> quit
Session sent command exit status 0
Main session channel closed
All channels closed

第三方几个月前确实移动了 SFTP 服务器,但据我所知,-b 参数在他们的新主机上仍然有效(但我可能错了)。

据我所知,我们这边没有任何变化,并且如所示,我们正在使用相同的本地登录 Windows 用户、相同的本地文件等进行 A/B 测试。应该不存在本地权限问题,因为我们使用的是 Windows,并且登录的帐户正在打开/编辑/访问所有相关文件。我还尝试将 -b 参数移动到行命令中的不同位置。

这个错误可能是远程 SFTP 服务器上的安全、配置或格式设置导致与 -b 命令文件混淆吗?

注意:我已经与操作远程 SFTP 主机的人员开具了一张票据,以对该问题进行三角测量,如果我能解决这个问题,我会在这里发布答案,以防它能帮助其他人看到 -b 开关上的“致命:无法打开”

psftp
  • 1 1 个回答
  • 63 Views

1 个回答

  • Voted
  1. Best Answer
    tb1
    2025-01-30T22:42:40+08:002025-01-30T22:42:40+08:00

    我明白了:具有讽刺意味的是,使用当前版本的 psftp 时会出现 -b“致命:无法打开”问题,该版本是 Windows 版 PuTTY(0.82)的一部分,是当前版本。

    预发布版本 0.83 与 -b 参数配合良好: https ://www.chiark.greenend.org.uk/~sgtatham/putty/prerel.html

    我很惊讶在网络搜索中没有听到任何关于此问题的讨论。:-/ 感谢您的聆听 / 我希望这可以帮助其他人。

    • 0

相关问题

  • 为什么 PSFTP 脚本在作为系统运行时会失败?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve