8

Trying to connect to a server. I've received a private key to login to that server which I added to id_rsa. However the client keeps attempting to pass that as the public key instead of id_rsa.pub. Is this because id_rsa.pub isn't in my ssh_config file?

SERVER CONNECTION ATTEMPT

debug1: Offering RSA public key: /root/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51

SSH CONFIG FILE (IDENTITY SECTION)

root@etoorlan4c:~/.ssh# cat /etc/ssh/ssh_config
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa

CONTENTS OF ~/.ssh/

root@etoorlan4c:~/.ssh# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
6
  • 2
    Are you sure this is the private key ? ssh can compute public key from private.
    – Archemar
    Sep 26, 2016 at 5:30
  • I copied and pasted it directly from the remote server. However running ssh-keygen -i returns uudecode failed. which the IBM site says means the key file is incorrect. I'm skeptical of the error because if I run ssh-keygen to make a new keypair, ssh-keygen -i still throws an error: Enter file in which the key is (/root/.ssh/id_rsa): decode blob failed: invalid format
    – Info5ek
    Sep 26, 2016 at 5:38
  • From what (other than the potentially misleadingly named debug message) to you conclude your private key is offered? In particular, look for debug1: identity file further up in your connection log to see if ssh recognizes it. Sep 26, 2016 at 6:06
  • debug1: identity file /root/.ssh/id_rsa type 1 there's no mention anywhere in these connection logs of id_rsa.pub
    – Info5ek
    Sep 26, 2016 at 6:09
  • 3
    Even though your problem was unrelated, I want to reiterate what @Archemar said. You can basically think of the public key as being embedded inside of the private key. Offering RSA public key: /root/.ssh/id_rsa means that it is offering the public key that it gets from your private key file.
    – cowlinator
    Apr 26, 2018 at 23:26

1 Answer 1

7

The private key was invalid. A single character was missing from it. The output changes as follows when a valid private key is used:

debug1: Offering RSA public key: root@etoorlan4c
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: sshkey.private
debug3: sign_and_send_pubkey: RSA SHA256:jmMyCOppv3KKkRgiHI4s5h3I7LwyCgms8uSG06KClQ4
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to [remoteHost]([xxx.xxx.xxx.xxx]:22).

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