macos Mac 终端在通过 SSH 使用 PPK 时不断询问密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9383437/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mac Terminal Keeps Asking for Password When Using PPK with SSH
提问by Chris
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."
我正在尝试通过 Mac 终端连接到 Amazon EC2 服务器。我有一个没有附加密码的 PPK 文件,但是当我尝试连接时,我看到一个弹出框,上面写着“输入 SSH 私钥的密码”。
So we tried creating a PPK that has a password - but it does not accept the password, it still rejects the connection.
所以我们尝试创建一个有密码的 PPK - 但它不接受密码,它仍然拒绝连接。
I have a Windows user who is able to connect using the same PPK on Putty.
我有一个 Windows 用户,他可以在 Putty 上使用相同的 PPK 进行连接。
Has anyone experienced this issue?
有没有人遇到过这个问题?
回答by bwight
The mac is looking for a .pem key. The ppk is generated specifically for putty. If you don't have the original ppk key.
mac 正在寻找 .pem 密钥。ppk 是专门为腻子生成的。如果您没有原始 ppk 密钥。
Download puttygen.exe from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.htmlThen go to conversions -> export OpenSSH key. Save the output as a .pem file and try using that with the mac.
从http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html下载 puttygen.exe然后转到转换 -> 导出 OpenSSH 密钥。将输出另存为 .pem 文件并尝试在 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.
如果这不起作用,您可以发布您从 mac 运行的命令。您可能有一些额外的参数或其他东西。
回答by bwight
Maybe your problem is with permissions for your key. I know in linux its required to change the permissions.
也许您的问题在于您的密钥权限。我知道在 linux 中需要更改权限。
Taken from the website http://om4.com.au/ssh-rsa-key-pairs-passphrases-leopard/
取自网站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 目录内容并将目录权限设置为 700(目录需要是“可执行的”) $ rm ~/.ssh/* $ chmod 700 ~/.ssh
生成您的 rsa 密钥对(对此有一些变体,但这是我使用的版本):$ ssh-keygen -t rsa
将 ~/.ssh 中所有文件的权限设置为 600 $ chmod 600 ~/.ssh
将您的 id_rsa.pub 密钥复制到您服务器的 .ssh/authorized_keys 文件
使用以下命令将您的密码添加到您的钥匙串:$ ssh-add -K(您将看到 Enter passphrase for [your system]/.ssh/id_rsa: )
回答by Benedict
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.
该错误Enter your password for the SSH key x
可能是因为在 ssh 或 sftp 中使用了错误格式的密钥(例如 ppk 密钥)。这是因为它被解释为加密的 ssh 密钥,因此提示输入密码,而实际上没有密码。
In OS X I was able to simulate this error by simply typing the following into the command line:
在 OS XI 中,只需在命令行中键入以下内容即可模拟此错误:
sftp -o IdentityFile=randomtextfile mysftpserver.com
The solution is to convert the file using puttygen as suggested by bwight.
解决方案是按照 bwight 的建议使用 puttygen 转换文件。
回答by Franck Dernoncourt
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.
例如ssh -i francky.pem 208.52.170.43
,在 Mac 上会询问您的密码,而不ssh -i francky.pem [email protected]
应该。请注意,在 Linux 上您不指定用户。
回答by reza
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
我在 MAC 中遇到了完全相同的问题,我找到了一种非常简单的方法来摆脱它。而不是使用 ssh -i IP 地址,使用以下> ssh user@IP
Hope you already found the answer after this long time :)
希望你在这么长时间后已经找到了答案:)
回答by pmartinezd
In my case, the problem was the file's break type. Try this:
就我而言,问题在于文件的中断类型。试试这个:
1.- Open the .pem file with TextWrangler
1.- 用 TextWrangler 打开 .pem 文件
2.- At Bottom of app, verify if the Break Type is "Windows(CRLF)".
2.- 在应用程序底部,验证中断类型是否为“Windows(CRLF)”。
回答by Neil H
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.
这个问题让我把头发拉了 20 分钟左右。意识到我能够从另一个终端窗口成功连接。在我的情况下,我只需要关闭当前的终端窗口并使用另一个或新窗口。很奇怪,但可能会帮助你。