WinSCP 无法使用公钥向我的服务器进行身份验证

WinSCP 无法使用公钥向我的服务器进行身份验证

我需要能够将文件上传到 Google Cloud 上虚拟机实例上的服务器。我遵循了以下教程: https://www.youtube.com/watch?v=o_OQEydt3MI

  • 我已经通过 PuTTY 密钥生成器生成了密钥
  • 关键评论:我输入了用于登录云控制台的 Gmail 地址(没有 ...@gmail 部分,就像在教程中一样)
  • 我已输入密钥密码
  • 在实例详细信息中我粘贴了我的 SSH 密钥
  • 在 WinSCP 高级设置中,我按照教程中的配置进行了配置(我提供了我的公钥文件),但仍然无法连接到我的服务器。我收到一条错误:“没有可用的受支持的身份验证方法(服务器发送:publickey、gssapi-keyhex、gssapi-with-mic)”。

我遗漏了什么吗?也许是一些防火墙配置?我应该在 Centos7 上为 SCP 安装一些东西吗?

WinSCP 日志:

. 2022-01-21 22:43:51.941 Session name: root@serverIP (Site)
. 2022-01-21 22:43:51.941 Host name: serverIp (Port: 22)
. 2022-01-21 22:43:51.941 User name: myGmail (Password: No, Key file: Yes, Passphrase: No)
. 2022-01-21 22:43:51.941 Tunnel: No
. 2022-01-21 22:43:51.941 Transfer Protocol: SFTP
. 2022-01-21 22:43:51.941 Ping type: Off, Ping interval: 30 sec; Timeout: 15 sec
. 2022-01-21 22:43:51.941 Disable Nagle: No
. 2022-01-21 22:43:51.941 Proxy: None
. 2022-01-21 22:43:51.941 Send buffer: 262144
. 2022-01-21 22:43:51.941 SSH protocol version: 2; Compression: No
. 2022-01-21 22:43:51.941 Bypass authentication: No
. 2022-01-21 22:43:51.941 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: Yes
. 2022-01-21 22:43:51.941 GSSAPI: KEX: No; Forwarding: No; Libs: gssapi32,sspi,custom; Custom: 
. 2022-01-21 22:43:51.941 Ciphers: aes,chacha20,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2022-01-21 22:43:51.941 KEX: ecdh,dh-gex-sha1,dh-group14-sha1,rsa,WARN,dh-group1-sha1
. 2022-01-21 22:43:51.941 SSH Bugs: Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto
. 2022-01-21 22:43:51.941 Simple channel: Yes
. 2022-01-21 22:43:51.941 Return code variable: Autodetect; Lookup user groups: Auto
. 2022-01-21 22:43:51.941 Shell: default
. 2022-01-21 22:43:51.941 EOL: LF, UTF: Auto
. 2022-01-21 22:43:51.941 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes; Follow directory symlinks: No
. 2022-01-21 22:43:51.941 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No; Exit code 1 is error: No
. 2022-01-21 22:43:51.941 SFTP Bugs: Auto,Auto
. 2022-01-21 22:43:51.941 SFTP Server: su -c /usr/libexec/openssh/sftp-server
. 2022-01-21 22:43:51.941 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2022-01-21 22:43:51.941 Cache directory changes: Yes, Permanent: Yes
. 2022-01-21 22:43:51.941 Recycle bin: Delete to: No, Overwritten to: No, Bin path: 
. 2022-01-21 22:43:51.941 DST mode: Unix
. 2022-01-21 22:43:51.941 --------------------------------------------------------------------------
. 2022-01-21 22:43:51.963 Looking up host "serverIp" for SSH connection
. 2022-01-21 22:43:51.963 Connecting to (serverIp) port 22
. 2022-01-21 22:43:52.015 Waiting for the server to continue with the initialization
. 2022-01-21 22:43:52.015 We claim version: SSH-2.0-WinSCP_release_5.19.4
. 2022-01-21 22:43:52.015 Detected network event
. 2022-01-21 22:43:52.059 Detected network event
. 2022-01-21 22:43:52.059 Waiting for the server to continue with the initialization
. 2022-01-21 22:43:52.059 Remote version: SSH-2.0-OpenSSH_7.4
. 2022-01-21 22:43:52.059 Using SSH protocol version 2
. 2022-01-21 22:43:52.060 Have a known host key of type ssh-ed25519
. 2022-01-21 22:43:52.103 Detected network event
. 2022-01-21 22:43:52.103 Waiting for the server to continue with the initialization
. 2022-01-21 22:43:52.103 Doing ECDH key exchange with curve Curve25519 and hash SHA-256
. 2022-01-21 22:43:52.156 Detected network event
. 2022-01-21 22:43:52.156 Waiting for the server to continue with the initialization
. 2022-01-21 22:43:52.192 Server also has ecdsa-sha2-nistp256/ssh-rsa host keys, but we don't know any of them
. 2022-01-21 22:43:52.192 Host key fingerprint is:
. 2022-01-21 22:43:52.192 ssh-ed25519 255 (I censored)
. 2022-01-21 22:43:52.192 Verifying host key ssh-ed25519 (I've censored)  with fingerprints ssh-ed25519 255 (I've censored)
. 2022-01-21 22:43:52.204 Host key matches cached key
. 2022-01-21 22:43:52.204 Initialised AES-256 SDCTR (AES-NI accelerated) [aes256-ctr] outbound encryption
. 2022-01-21 22:43:52.204 Initialised HMAC-SHA-256 outbound MAC algorithm
. 2022-01-21 22:43:52.204 Initialised AES-256 SDCTR (AES-NI accelerated) [aes256-ctr] inbound encryption
. 2022-01-21 22:43:52.204 Initialised HMAC-SHA-256 inbound MAC algorithm
. 2022-01-21 22:43:52.248 Detected network event
. 2022-01-21 22:43:52.248 Waiting for the server to continue with the initialization
. 2022-01-21 22:43:52.248 Reading key file "C:\myPath\public_key_my_key.ppk"
. 2022-01-21 22:43:52.248 Key file contains public key only
! 2022-01-21 22:43:52.248 Using username "myGmail".
. 2022-01-21 22:43:52.429 Detected network event
. 2022-01-21 22:43:52.429 Waiting for the server to continue with the initialization
. 2022-01-21 22:43:52.429 Server offered these authentication methods: publickey,gssapi-keyex,gssapi-with-mic
. 2022-01-21 22:43:52.429 Using SSPI from SECUR32.DLL
. 2022-01-21 22:43:52.429 Trying gssapi-with-mic...
. 2022-01-21 22:43:52.429 Attempting GSSAPI authentication
. 2022-01-21 22:43:52.474 Detected network event
. 2022-01-21 22:43:52.474 Waiting for the server to continue with the initialization
. 2022-01-21 22:43:52.474 GSSAPI authentication request refused
. 2022-01-21 22:43:52.474 Server offered these authentication methods: publickey,gssapi-keyex,gssapi-with-mic
. 2022-01-21 22:43:52.474 No supported authentication methods available (server sent: publickey,gssapi-keyex,gssapi-with-mic)
. 2022-01-21 22:43:52.474 Attempt to close connection due to fatal exception:
* 2022-01-21 22:43:52.474 No supported authentication methods available (server sent: publickey,gssapi-keyex,gssapi-with-mic)
. 2022-01-21 22:43:52.474 Closing connection.
* 2022-01-21 22:43:52.533 (EFatal) No supported authentication methods available (server sent: publickey,gssapi-keyex,gssapi-with-mic)
* 2022-01-21 22:43:52.533 Authentication log (see session log for details):
* 2022-01-21 22:43:52.533 Using username "myGmail".
* 2022-01-21 22:43:52.533 
* 2022-01-21 22:43:52.533 Authentication failed.

答案1

您无法通过身份验证民众密钥文件。您必须使用私钥文件。


事实上,WinSCP 甚至在设置中接受公钥文件。但这只能作为一种方式来告诉它,从 Pageant 加载哪个特定的私钥(如果您在 Pageant 中加载了多个密钥)。如果您不使用 Pageant,那么公钥对于身份验证毫无用处。

https://winscp.net/eng/docs/ui_login_authentication#private_key

相关内容