我正在使用 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 和脚本的完整会话日志文件。