WinSCP SSH错误未知命令'ssh-rsa'

问题描述 投票:0回答:1

上下文:我有通过BCP从SQL Server输出的CSV文件。我正在尝试使用WinSCP将文件安全地传输到远程SFTP文件夹。

详细信息:当我通过powershell执行下面的批处理文件时,我引发错误'未知命令'ssh-rsa',日志文件显示退出代码= 1,这是失败的。

这是我的同步文件的样子......

option batch abort
option confirm off
open sftp://username:[email protected] -hostkey="ssh-rsa 2048 redacted=ssh-rsa 2048 redacted"
synchronize remote D:\redactedDaily_Reports\redacted_Catalog_New_Item /upload/redacted_catalog
exit

和我的批处理文件......

winscp.com /script=SyncTo_redacted_catalog.txt /log=D:\redacted_Daily_Reports\winscp_log_catalog.txt
pause

这是我的powershell输出和日志文件的片段... powershell output

. 2019-03-06 23:39:28.379 Access granted
. 2019-03-06 23:39:28.379 Opening session as main channel
. 2019-03-06 23:39:28.447 Opened main channel
. 2019-03-06 23:39:28.583 Started a shell/command
. 2019-03-06 23:39:28.583 --------------------------------------------------------------------------
. 2019-03-06 23:39:28.584 Using SFTP protocol.
. 2019-03-06 23:39:28.584 Doing startup conversation with host.
> 2019-03-06 23:39:28.584 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2019-03-06 23:39:28.769 Type: SSH_FXP_VERSION, Size: 95, Number: -1
. 2019-03-06 23:39:28.769 SFTP version 3 negotiated.
. 2019-03-06 23:39:28.769 Unknown server extension [email protected]="1"
. 2019-03-06 23:39:28.769 Supports [email protected] extension version "2"
. 2019-03-06 23:39:28.769 Unknown server extension [email protected]="2"
. 2019-03-06 23:39:28.769 We believe the server has signed timestamps bug
. 2019-03-06 23:39:28.769 We will use UTF-8 strings until server sends an invalid UTF-8 string as with SFTP version 3 and older UTF-8 strings are not mandatory
. 2019-03-06 23:39:28.769 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
. 2019-03-06 23:39:28.769 Getting current directory name.
. 2019-03-06 23:39:28.769 Getting real path for '.'
> 2019-03-06 23:39:28.769 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2019-03-06 23:39:28.837 Type: SSH_FXP_NAME, Size: 23, Number: 16
. 2019-03-06 23:39:28.837 Real path is '/'
. 2019-03-06 23:39:28.837 Startup conversation with host finished.
< 2019-03-06 23:39:28.837 Script: Active session: [1] [email protected]
> 2019-03-06 23:39:28.838 Script: ssh-rsa 2048 redacted
< 2019-03-06 23:39:28.838 Script: Unknown command 'ssh-rsa'.
. 2019-03-06 23:39:28.838 Script: Failed
. 2019-03-06 23:39:28.838 Script: Exit code: 1
. 2019-03-06 23:39:28.838 Closing connection.
. 2019-03-06 23:39:28.838 Sending special code: 12
. 2019-03-06 23:39:28.838 Sent EOF message

问题:为什么我提出此错误以及如何解决?这个错误是否试图告诉我我使用了错误的密钥指纹 - 如果是这样的话,为什么会出现这样的情况:a)我第一次成功连接时直接从服务器获取此密钥并且b)日志文件似乎显示初始连接成功?

请帮助任何提示或建议非常感谢 - 鉴于winscp是一个非常受欢迎的实用程序,响应可能会达到一个相当大的观众。我做了我的研究hereherehereherehereherehere并没有找到合适的解决方案。

powershell ssh sftp file-transfer winscp
1个回答
-1
投票

这是无稽之谈: -hostkey="ssh-rsa 2048 redacted=ssh-rsa 2048 redacted" (你在哪里见过这么奇怪的语法?)

它应该是:-hostkey="ssh-rsa 2048 xxxxxxxxxxx...="

虽然它没有真正解释你得到的错误信息 - 除非redacted部分中有一些特殊字符(如双引号)。


一般来说,最简单的方法是为你have WinSCP GUI generate correct script template


或者,如果您想以手动方式,请参阅: Where do I get SSH host key fingerprint to authorize the server? 特别是“自动主机密钥验证”部分(尽管您将从头开始阅读文章)。

我知道你自己参考这篇文章。但后来我不明白你是如何达到你的奇怪语法的。

© www.soinside.com 2019 - 2024. All rights reserved.