Monday, March 14, 2022

[SOLVED] SSH Key does not work on a fresh linux install

Issue

I recently re installed my OS (Mint 17.1) and wanted to use my ssh keys to connect to git. I have used this key in many places with no problems until now. There are a lot of answers out there about this issue but none of them helped me so far.

.ssh directory has 0700 permissions

So the output I am getting is this:

ssh -vT [email protected]
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/herod/.ssh/config
debug1: /home/herod/.ssh/config line 1: Applying options for *
debug1: /home/herod/.ssh/config line 9: Applying options for github.com
debug1: /home/herod/.ssh/config line 14: Applying options for github.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [192.30.252.128] port 22.
debug1: Connection established.
debug1: identity file /home/herod/.ssh/xxxx/id_rsa.pub type 1
debug1: identity file /home/herod/.ssh/xxxx/id_rsa.pub-cert type -1
debug1: identity file /home/herod/.ssh/xxxx2222/id_rsa.pub type 1
debug1: identity file /home/herod/.ssh/xxxx2222/id_rsa.pub-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version libssh-0.6.0
debug1: no match: libssh-0.6.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/herod/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/herod/.ssh/xxxx/id_rsa.pub
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/home/herod/.ssh/xxxx/id_rsa.pub': 
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>

Solution

This worked for me (answer taken from here):

"For me since the key itself was encrypted, I followed the following steps:

Start ssh-agent:

$ ssh-agent bash

Add standard identity key to the key manager:

$ ssh-add

If you want to add a different key, then:

$ ssh-add /location/of/key

To inspect at any time, the list of currently loaded keys:

$ ssh-add -l More details can be obtained from this link"

As an add on to @Kenster comment and to the solution here when you add the key you will have to add the private key

$ ssh-add /location/of/key (ex ssh-add .ssh/folder/id_rsa)

and not

$ ssh-add /location/of/key.pub (ex ssh-add .ssh/folder/id_rsa.pub)



Answered By - Herr Nentu'
Answer Checked By - Pedro (WPSolving Volunteer)