Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  1. The pem file is generated by AWS console
  2. I was able to connect using the EC2 remote web interface, using the same pem file
  3. The permission of pem is 600 already


ssh -i ~/test.pem -v

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/john/test.pem
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/home/john/test.pem':

Anyone can help?

share|improve this question
Presuming that you know the passphrase, you can remove it with: openssl rsa -in test.pem -out test-nopass.pem (which will prompt you for the passphrase and save the unencrypted key for you). If this is not the case, your key may have been inadvertently modified at some point, in which case, you will need a backup of the original key to get back into those instances using that key. – cyberx86 Apr 16 '12 at 17:28
There is no passphrease. I can use the same pem file in AWS web interface for remote login without any passphrase. – Howard Apr 16 '12 at 17:51
Depending on how you saved your key, the problem could be line-endings (the Java client is likely more lax than openSSH on this front). This is more likely if you copied and pasted the output (as opposed to redirecting the output). Check the key with openssl rsa -in test.pem -check and (even though you don't have a passphrase) try the command suggested earlier (and then change your ssh command to use the new key file) as it will write the key to a new file (possibly fixing the problem if it is just a line-ending issue, if it can read the file). – cyberx86 Apr 16 '12 at 18:22
up vote -5 down vote accepted

If you try to establish a ssh connection from a ssh connection on ec2, use notepad to open .pem file on your local machine. It will work 100% and won't ask you for any passphrase.

share|improve this answer
This answer makes no sense. What specific course of action are you trying to suggest? – voretaq7 Jun 11 '13 at 0:34

I had this issue when I was trying to login from a NAT instance that I set up. The NAT instance is not something I can specify (to the best of knowledge) what OS to use, and I presume that it is using AWS CentOS. Anyways, I was always being asked for a passphrase when trying to connect to an instance on my private network. Here was how i resolved it, although it wasn't entirely apparent to me at the time.

[ec2-user@ip-10-2-3-192 ~]$ sudo bash
[root@ip-10-2-3-192 ~]$ ssh -i /home/test.pem ubuntu@

Hope this helps

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.