![WinSCP 命令行“put”失败并显示“无法验证” - 在 GUI 中有效](https://linux22.com/image/1523830/WinSCP%20%E5%91%BD%E4%BB%A4%E8%A1%8C%E2%80%9Cput%E2%80%9D%E5%A4%B1%E8%B4%A5%E5%B9%B6%E6%98%BE%E7%A4%BA%E2%80%9C%E6%97%A0%E6%B3%95%E9%AA%8C%E8%AF%81%E2%80%9D%20-%20%E5%9C%A8%20GUI%20%E4%B8%AD%E6%9C%89%E6%95%88.png)
我正在使用 WinSCP 将文件复制到服务器。
我们正在将它与 GUI 一起使用。
我现在想自动执行这一步并从命令行使用 WinSCP。
不幸的是,我们“无法验证”。
以下是使用 GUI 进行身份验证的相关日志片段:
! 2017-03-04 00:23:05.959 Using username "goofy".
. 2017-03-04 00:23:06.115 Server offered these authentication methods: publickey,password,keyboard-interactive
. 2017-03-04 00:23:06.115 Attempting keyboard-interactive authentication
. 2017-03-04 00:23:06.162 Prompt (keyboard interactive, "SSH server authentication", "Using keyboard-interactive authentication.", "Password: ")
. 2017-03-04 00:23:06.162 Using stored password.
. 2017-03-04 00:23:06.333 Prompt (keyboard interactive, "SSH server authentication", <no instructions>, <no prompt>)
. 2017-03-04 00:23:06.333 Ignoring empty SSH server authentication request
. 2017-03-04 00:23:06.380 Access granted
以下是命令行拒绝的相关日志片段:
! 2017-03-04 00:10:33.353 Using username "goofy".
. 2017-03-04 00:10:33.400 Server offered these authentication methods: publickey,password,keyboard-interactive
. 2017-03-04 00:10:33.400 Attempting keyboard-interactive authentication
. 2017-03-04 00:10:33.431 Prompt (keyboard interactive, "SSH server authentication", "Using keyboard-interactive authentication.", "Password: ")
. 2017-03-04 00:10:33.431 Using stored password.
. 2017-03-04 00:10:33.587 Keyboard-interactive authentication failed
! 2017-03-04 00:10:33.587 Access denied
. 2017-03-04 00:10:33.587 Server offered these authentication methods: publickey,password,keyboard-interactive
. 2017-03-04 00:10:33.587 Attempting keyboard-interactive authentication
. 2017-03-04 00:10:33.665 Prompt (keyboard interactive, "SSH server authentication", "Using keyboard-interactive authentication.", "Password: ")
. 2017-03-04 00:10:33.665 Disconnected: Unable to authenticate
这是我们使用的命令行:
"%winscp%" /ini=nul ^
/log=C:\TEMP\winscplog.txt ^
/command "open sftp://goofy:[email protected]/ -hostkey=""ssh-rsa 2048 d4:1c:1a:4c:c3:60:d5:05:12:02:xx:xx:xx:xx:xx:xx""" ^
"put ""%outfile%"" /home/public/uploadarea/%basename%" ^
"exit"
注意:在命令行上输入密码并不是一个好习惯,因此如果您以此为示例,请不要将其视为最佳做法。
答案1
提取与您特别相关的部分:
启用密码日志并确保在 GUI 和脚本中使用相同的密码。
在 GUI 中,您可以在偏好设置中启用密码登录。在脚本中,您可以使用/loglevel=*
命令行开关。
你也可以使用 GUI为您生成脚本模板。
如果这没有帮助,我们需要查看 GUI 和脚本的完整会话日志文件。