如何将另一个私有/公共密钥对(由 PuTTY 生成)用于 ssh?

Emr*_*inç 1 ssh putty

我使用 PuTTY 从我的 MS Windows 工作站连接到我的一台 Linux 服务器(我使用 PuTTY 相关工具之一在 MS Windows 上生成它们,我不记得我在生成密钥时使用了哪些参数)。现在我正在尝试从我的 Ubuntu GNU/Linux 工作站连接到同一台服务器。我的 ~/.ssh 中已经有私钥/公钥对:

id_rsa
id_rsa.pub
Run Code Online (Sandbox Code Playgroud)

现在,除了我已经拥有的那些私钥/公钥对之外,我还想添加私钥/公钥对以连接到我的 Linux 服务器。对于 PuTTY,我有两个文件可以让我成功连接到我的 Linux 服务器:

emrePrivate.ppk
emrePublic.pub
Run Code Online (Sandbox Code Playgroud)

我已将上述文件复制到我的 ~/.ssh 目录中。然后我尝试使用以下命令连接到我的服务器:

$ ssh -v -i /home/emre/.ssh/emrePrivate.ppk emre@yafz.org
Run Code Online (Sandbox Code Playgroud)

但我看到它试图使用错误的公钥。这是输出:

OpenSSH_5.3p1 Debian-3ubuntu4, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to yafz.org [109.74.204.147] port 22.
debug1: Connection established.
debug1: identity file /home/emre/.ssh/emrePrivate.ppk type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-6ubuntu2
debug1: match: OpenSSH_5.1p1 Debian-6ubuntu2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu4
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'yafz.org' is known and matches the RSA host key.
debug1: Found key in /home/emre/.ssh/known_hosts:3
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: emre.sevinc@gmail.com
debug1: Authentications that can continue: publickey
debug1: Offering public key: /home/emre/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/emre/.ssh/emrePrivate.ppk
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/home/emre/.ssh/emrePrivate.ppk': 
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/home/emre/.ssh/emrePrivate.ppk': 
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,它不接受我的密码。我还尝试将 emrePrivate.ppk 复制到 id_rsa,然后将 emrePublic.pub 复制到 id_rsa.pub,但我仍然无法连接到我的 Linux 服务器。

我特别担心这些行:

debug1: Offering public key: emre.sevinc@gmail.com
debug1: Authentications that can continue: publickey
debug1: Offering public key: /home/emre/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)

但我找不到如何解决这个问题。

有任何想法吗?

Sve*_*ven 5

您的公钥必须在目标框的 ~/.ssh/authorized_keys 中。如果您想要多个键,只需将它们复制到目标框并像这样附加它们:

cat id_rsa.pub >> ~/.ssh/authorized_keys
Run Code Online (Sandbox Code Playgroud)

此外,阅读此信息约腻子键保持兼容,以及如何转换键。