Debugging SSH

Debugging ssh is monotonous, monotonous, monotonous, monotonous shit ‘cos you get reams of messages which don’t tell you why you can’t connect.

E.g.

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

Actual error message should be:

YOU'VE PROBABLY REPLACED YOUR HOST AND YOUR EXISTING KEY IN ~/.ssh/known_hosts DOES NOT MATCH

Delete your key on line 293.

Permission denied (publickey).

This one is guaranteed to waste at least several months of your life.

Check:

  • Your public key is in the ~/.ssh/authorized_keys file of the user you’re trying to login with on the destination server
  • Your private key matches that public key (use ssh-keygen -y -e -f .ssh/id_rsa to output the public key version of the private key)
  • Your private key has the correct permissions

Use ssh -v to debug. Ignore the 20 odd lines of useless information that get output and focus on:

debug1: Offering public key: RSA SHA256:hash /Users/snowcrash/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering public key: RSA SHA256:hash /Users/snowcrash/.ssh/another_key
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
snowcrash@1.2.3.4: Permission denied (publickey).

Output to look out for:

  1. debug1: identity file /home/snowcrash/.ssh/id_rsa type -1
    The -1 => it doesn’t exist. If it’s a 0 then you’re good.

 

Here’s a few pretty useless StackOverflow articles:

  1. https://superuser.com/questions/1137438/ssh-key-authentication-fails/1145465

Fails here: Watch the messages file tail -l /var/log/messages

tail: cannot open ‘/var/log/messages’ for reading: No such file or directory

2.

Leave a Reply

Your email address will not be published. Required fields are marked *