将 PPK 与 SSH 结合使用时,Mac 终端不断要求输入密码

发布于 2025-01-07 09:25:25 字数 213 浏览 0 评论 0 原文

我正在尝试通过 Mac 终端连接到 Amazon EC2 服务器。我有一个没有附加密码的 PPK 文件,但是当我尝试连接时,会出现一个弹出框,显示“输入 SSH 私钥的密码”。

因此,我们尝试创建一个具有密码的 PPK - 但它不接受密码,它仍然拒绝连接。

我有一个 Windows 用户能够在 Putty 上使用相同的 PPK 进行连接。

有人经历过这个问题吗?

I am attempting to connect to an Amazon EC2 Server via Mac Terminal. I have a PPK file that does not have a password attached to it, but when I try to connect I get a popup box that says "Enter the password for the SSH Private Key."

So we tried creating a PPK that has a password - but it does not accept the password, it still rejects the connection.

I have a Windows user who is able to connect using the same PPK on Putty.

Has anyone experienced this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

爱她像谁 2025-01-14 09:25:25

Mac 正在寻找 .pem 密钥。 ppk 是专门为 putty 生成的。如果您没有原始 ppk 密钥。

http://www.chiark.greenend.org.uk/~sgtatham 下载 puttygen.exe /putty/download.html 然后进入转换->导出 OpenSSH 密钥。将输出保存为 .pem 文件并尝试在 Mac 上使用它。

如果这不起作用,您可以发布您从 mac 运行的命令。您可能有一些额外的参数或其他东西。

The mac is looking for a .pem key. The ppk is generated specifically for putty. If you don't have the original ppk key.

Download puttygen.exe from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html Then go to conversions -> export OpenSSH key. Save the output as a .pem file and try using that with the mac.

If this doesn't work can you post the command you're running from mac. Its possible you've got some extra parameter or something.

剪不断理还乱 2025-01-14 09:25:25

也许您的问题在于您的密钥的权限。我知道在linux中需要更改权限。

取自网站 http://om4.com.au/ssh- rsa-key-pairs-passphrases-leopard/

  1. 清除 ~/.ssh 目录的内容并将目录权限设置为 700(目录需要“可执行”)
    $ rm ~/.ssh/*
    $ chmod 700 ~/.ssh

  2. 生成你的 rsa 密钥对(有一些变体,但这是我使用的版本):
    $ ssh-keygen -t rsa

  3. 将~/.ssh中所有文件的权限设置为600
    $ chmod 600 ~/.ssh

  4. 将 id_rsa.pub 密钥复制到服务器的 .ssh/authorized_keys 文件

  5. 将密码短语添加到使用此命令的钥匙串:
    $ ssh-添加-K
    (您将看到 Enter passphrase for [your system]/.ssh/id_rsa: )

Maybe your problem is with permissions for your key. I know in linux its required to change the permissions.

Taken from the website http://om4.com.au/ssh-rsa-key-pairs-passphrases-leopard/

  1. Clear the contents of your ~/.ssh directory and set the directory permissions to 700 (directories need to be "executable")
    $ rm ~/.ssh/*
    $ chmod 700 ~/.ssh

  2. Generate your rsa key pair (there are variations for this, but this is the version I used):
    $ ssh-keygen -t rsa

  3. Set the permissions for all files in ~/.ssh to 600
    $ chmod 600 ~/.ssh

  4. Copy your id_rsa.pub key to your server’s .ssh/authorized_keys file

  5. Add your passphrase to your keychain using this command:
    $ ssh-add -K
    (you will see Enter passphrase for [your system]/.ssh/id_rsa: )

别理我 2025-01-14 09:25:25

请输入 SSH 密钥 x 的密码错误可能是由于在 ssh 或 sftp 中使用错误格式的密钥(例如 ppk 密钥)而导致的。这是因为它被解释为加密的 ssh 密钥,因此会提示输入密码,而实际上没有密码。

在 OS XI 中,只需在命令行中键入以下内容即可模拟此错误:

sftp -o IdentityFile=randomtextfile mysftpserver.com

解决方案是按照 bwight 的建议使用 puttygen 转换文件。

The error Enter your password for the SSH key x can result from using a key of the wrong format (such as a ppk key) in ssh or sftp. This is because it is interpreted as an encrypted ssh key and so prompts for the passphrase, when actually there is no passphrase.

In OS X I was able to simulate this error by simply typing the following into the command line:

sftp -o IdentityFile=randomtextfile mysftpserver.com

The solution is to convert the file using puttygen as suggested by bwight.

Hello爱情风 2025-01-14 09:25:25

除了其他答案之外,问题可能来自于您尚未指定要以哪个用户身份进行连接。

例如,ssh -i francky.pem 208.52.170.43 会在 Mac 上询问您的密码,而 ssh -i francky.pem [电子邮件受保护] 不应该。请注意,在 Linux 上您无需指定用户。

In addition to the other answers, the issue might come from the fact you haven't specified which user you want to connect as.

For example ssh -i francky.pem 208.52.170.43 will ask you for your password on Mac, whereas ssh -i francky.pem [email protected] shouldn't. Note that on Linux you don't specify the user.

淡莣 2025-01-14 09:25:25

我在 MAC 中遇到了完全相同的问题,我找到了一个非常简单的方法来摆脱它。
不要使用 ssh -i IP 地址,而是使用以下命令>
ssh user@IP

希望这么长时间后你已经找到答案了:)

I was running into the exact same problem in MAC, I found a quite simple way of getting rid of it.
Instead of using ssh -i IP address, use the following>
ssh user@IP

Hope you already found the answer after this long time :)

稍尽春風 2025-01-14 09:25:25

就我而言,问题在于文件的中断类型。试试这个:

1.- 使用 TextWrangler 打开 .pem 文件

2.- 在应用程序底部,验证中断类型是否为“Windows(CRLF)”。

In my case, the problem was the file's break type. Try this:

1.- Open the .pem file with TextWrangler

2.- At Bottom of app, verify if the Break Type is "Windows(CRLF)".

鸩远一方 2025-01-14 09:25:25

这个问题让我拔头发了 20 分钟左右。意识到我能够从另一个终端窗口成功连接。就我而言,我只需关闭当前的终端窗口并使用另一个或新窗口。很奇怪,但可能对你有帮助。

This issue had me pulling my hair out for 20 min or so. Realized that I was able to connect successfully from another terminal window. In my case I just had to close out the current terminal window and use another or new window. Very strange, but may help you out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文