SSH:权限在 Cygwin 中被拒绝,但在 Putty 中可以工作

SSH:权限在 Cygwin 中被拒绝,但在 Putty 中可以工作

我正在尝试通过 SSH 连接到一台服务器,不是拥有 root 权限。我不喜欢使用 Putty,我更喜欢 Cygwin。我可以使用 Putty 登录服务器,但使用完全相同的私钥并输入完全相同的密码时,使用 Cygwin 时会出错。我尝试过使用和不使用 SSH 版本 2 强制,以及使用和不使用端口转发选项。结果相同。还尝试从我的 known_hosts 文件中删除主机,结果相同。

参见下文。出于安全考虑,更改了 IP 地址。

$  ssh -v -2 -i private_key.ppk -L 5432:localhost:5432 [email protected]

Connecting to 22.22.22.22
OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Connecting to 22.22.22.22 [22.22.22.22] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/private_key.ppk type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/private_key.ppk-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to 22.22.22.22:22 as 'user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client [email protected] <implicit> none
debug1: kex: client->server [email protected] <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:T1wfSekfyPulNsBaGn/d5ubEKy1VKWKmBcr/SQQTRSs
debug1: Host '22.22.22.22' is known and matches the ECDSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:58
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/user/.ssh/private_key.ppk
Enter passphrase for key '/home/user/.ssh/private_key.ppk':
Enter passphrase for key '/home/user/.ssh/private_key.ppk':
Enter passphrase for key '/home/user/.ssh/private_key.ppk':
debug1: No more authentication methods to try.
Permission denied (publickey).

“debug1: key_load_public: 没有这样的文件或目录”部分可能就是原因。但是,我可以使用相同的私钥通过 Putty 通过 SSH 进入该服务器,因此服务器上的密钥必须到位。

答案1

ppk 文件格式是 PuTTY 特有的。我认为您需要将其转换为通用格式。您可以使用 puttegen.exe 来执行此操作。

答案2

使用 cygwin,你可以用来ssh-keygen 制作密钥

您还可以使用“cat”命令,也许还有“file”命令,查看密钥并检查格式。显然,密钥格式有很多种。

相关内容