I have generated the keys in Ubuntu 14.04 system using the following commands to use with ssh.

 ssh-keygen -t rsa -b 2048
 openssl rsa -in id_rsa -outform pem > pk_rsa.pem
 openssl rsa -in pk_rsa.pem -pubout -out my_key.pem

I have copied the my_key.pem to my local which is OSX. Trying to ssh into the Ubuntu using the below command

 ssh -v -i ./my_key.pem ubuntu@ 
 OpenSSH_7.4p1, LibreSSL 2.5.0
 debug1: Reading configuration data /etc/ssh/ssh_config
 debug1: Connecting to [] port 22.
 debug1: Connection established.
 debug1: key_load_public: No such file or directory 
 debug1: identity file ./ubu14.pem type -1
 debug1: key_load_public: No such file or directory
 debug1: identity file ./ubu14.pem-cert type -1
 debug1: Enabling compatibility mode for protocol 2.0
 debug1: Local version string SSH-2.0-OpenSSH_7.4
 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
 debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000
 debug1: Authenticating to as 'ubuntu'
 debug1: SSH2_MSG_KEXINIT sent
 debug1: SSH2_MSG_KEXINIT received
 debug1: kex: algorithm: curve25519-sha256@libssh.org
 debug1: kex: host key algorithm: ecdsa-sha2-nistp256
 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
 debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
 debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
 debug1: Server host key: ecdsa-sha2-nistp256 SHA256:KDokJiZiQ9ZflT5Jm5B8krQ8XgsEEgUjQjg+h6C4Gqo
 debug1: Host '' is known and matches the ECDSA host key.
 debug1: Found key in /Users/macdev/.ssh/known_hosts:11
 debug1: rekey after 134217728 blocks
 debug1: SSH2_MSG_NEWKEYS sent
 debug1: expecting SSH2_MSG_NEWKEYS
 debug1: SSH2_MSG_NEWKEYS received
 debug1: rekey after 134217728 blocks
 debug1: SSH2_MSG_SERVICE_ACCEPT received
 debug1: Authentications that can continue: publickey,password
 debug1: Next authentication method: publickey
 debug1: Trying private key: ./my_key.pem
 Enter passphrase for key './my_key.pem': 
 debug1: Next authentication method: password
 mahesh@'s password: 

Is there way to fix this issue.

1 Answer 1


You are conflating two different technologies, openssh and openssl. It appears you need only the former.

As you have already created an ssh key pair, you just need to copy the public key to the server you intend to ssh to. The correct way to do this is:

$ ssh-copy-id username@<server-ip>

Replace username and <server-ip> with the user and IP address of your server.

  • i want to use the ssh-key generated in the server just like the pem file which we get from amazon ec2 instances so that I can login to server from different machines without password using the pem file.
    – mahesh
    Apr 28, 2017 at 8:29
  • @mahesh it won't prompt you for a password unless you set a password when creating the key.
    – Alxs
    Apr 28, 2017 at 8:37
  • I havn't set the password i left with empty passphrase while generating
    – mahesh
    Apr 28, 2017 at 8:42
  • @mahesh, okay did you ssh-copy-id username@<server-ip>?
    – Alxs
    Apr 28, 2017 at 8:45
  • No I haven't done
    – mahesh
    Apr 28, 2017 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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