将 PPK 与 SSH 结合使用时,Mac 终端不断要求输入密码
我正在尝试通过 Mac 终端连接到 Amazon EC2 服务器。我有一个没有附加密码的 PPK 文件,但是当我尝试连接时,会出现一个弹出框,显示“输入 SSH 私钥的密码”。
因此,我们尝试创建一个具有密码的 PPK - 但它不接受密码,它仍然拒绝连接。
我有一个 Windows 用户能够在 Putty 上使用相同的 PPK 进行连接。
有人经历过这个问题吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
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.
也许您的问题在于您的密钥的权限。我知道在linux中需要更改权限。
取自网站 http://om4.com.au/ssh- rsa-key-pairs-passphrases-leopard/
清除 ~/.ssh 目录的内容并将目录权限设置为 700(目录需要“可执行”)
$ rm ~/.ssh/*
$ chmod 700 ~/.ssh
生成你的 rsa 密钥对(有一些变体,但这是我使用的版本):
$ ssh-keygen -t rsa
将~/.ssh中所有文件的权限设置为600
$ chmod 600 ~/.ssh
将 id_rsa.pub 密钥复制到服务器的 .ssh/authorized_keys 文件
将密码短语添加到使用此命令的钥匙串:
$ 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/
Clear the contents of your ~/.ssh directory and set the directory permissions to 700 (directories need to be "executable")
$ rm ~/.ssh/*
$ chmod 700 ~/.ssh
Generate your rsa key pair (there are variations for this, but this is the version I used):
$ ssh-keygen -t rsa
Set the permissions for all files in ~/.ssh to 600
$ chmod 600 ~/.ssh
Copy your id_rsa.pub key to your server’s .ssh/authorized_keys file
Add your passphrase to your keychain using this command:
$ ssh-add -K
(you will see Enter passphrase for [your system]/.ssh/id_rsa: )
请输入 SSH 密钥 x 的密码
错误可能是由于在 ssh 或 sftp 中使用错误格式的密钥(例如 ppk 密钥)而导致的。这是因为它被解释为加密的 ssh 密钥,因此会提示输入密码,而实际上没有密码。在 OS XI 中,只需在命令行中键入以下内容即可模拟此错误:
解决方案是按照 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:
The solution is to convert the file using puttygen as suggested by bwight.
除了其他答案之外,问题可能来自于您尚未指定要以哪个用户身份进行连接。
例如,
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, whereasssh -i francky.pem [email protected]
shouldn't. Note that on Linux you don't specify the user.我在 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 :)
就我而言,问题在于文件的中断类型。试试这个:
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)".
这个问题让我拔头发了 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.