MobaXTerm-SSH 密钥认证

MobaXTerm-SSH 密钥认证

我有一个经过转换的密钥,可以与 Putty 配合使用。

我尝试过以下格式:

ssh -p 1111 -i id_rsa [email protected]

ssh -i id_rsa -p 1111 [email protected]

该密钥与 MobaXTerm 可执行文件位于同一文件夹中。

谢谢!

编辑:

[chip.client] $ ssh -p 1111 -i id_rsa [email protected] -v
Warning: Identity file id_rsa not accessible: No such file or directory.
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to 192.168.0.9 [192.168.0.100] port 1111.
debug1: Connection established.
debug1: identity file /home/chip/.ssh/id_rsa type -1
debug1: identity file /home/chip/.ssh/id_rsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3p1 Debian-3ubuntu7
debug1: match: OpenSSH_5.3p1 Debian-3ubuntu7 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 [email protected]
debug1: kex: client->server aes128-ctr hmac-md5 [email protected]
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: checking without port identifier
Warning: Permanently added '[192.168.0.100]:1111' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
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/chip/.ssh/id_rsa
debug1: No more authentication methods to try.
Permission denied (publickey).

[01/09/2011 - 09:15.38] ~

答案1

MobaXterm 默认使用主目录位置作为 Windows 临时目录。因此,一旦关闭 MobaXterm,您创建的密钥将不可用。

生成密钥后,将其保存在 Windows 驱动器中的不同文件夹中,并在“-i”选项中通过完整路径引用它。Windows 驱动器在 MobaXterm 中被称为“/drives/c/”、“drives/d/”等。如果私钥保存在 E:\keys\id_rsa,则命令将如下所示,

ssh -p 1111 -i /drives/e/keys/id_rsa [email protected]

如果您经常使用 MobaXterm,处理此问题的最佳方法是使用永久位置作为主目录,而不是默认的临时目录。您可以通过以下方式执行此操作:设置->配置->其他选项->使用以下持久主目录。在这种情况下,密钥可以保留在主目录中,您无需提供“i”选项

答案2

如果您已经通过 Putty 或其他方式设置了密钥,最简单的方法是将它们复制并粘贴到 MobaXterm 的 ssh 目录中。

复制它们然后将密钥粘贴到:C:\Users\%USERNAME%\Documents\MobaXterm\home\.ssh

笔记:

Putty 的默认位置通常是C:\Users\.ssh

Cygwin 的默认位置通常是C:\cygwin64\home\%USERNAME%\.ssh

答案3

我不确定 MobaXTerm 的登录环境是如何工作的。从您的输出中可以明显看出,ssh 正在寻找名为 /home/chip.ssh/id_rsa 的密钥。

那么,当您启动 MobaXTerm 时,您可以尝试一些东西,比如运行“pwd”并查看它认为它在哪个目录中,然后将密钥放入其中?在您的 ssh 命令中,您应该能够使用类似“ssh -i /path/to/ssh/key/id_rsa”以及您正在使用的其他 ssh 选项来指定密钥的完整路径。

或者,您可以指定一些替代路径。如果 MobaXTerm 基于 Cygwin,您可以说“/cygdrive/c/Documents/ssh/id_rsa”,这应该对应于文件系统上的“C:\Documents\ssh\id_rsa”。

相关内容