Can't establish ssh connection to IP address but can to git

30 Views Asked by At

I am trying to deploy a website from my github repository to Digital Ocean, however I'm unable to ssh into my Digital Ocean droplet. (Very new to this - please pardon any obvious issues) I get this error:

alexschutz@Alexs-MBP ~ % ssh -v root@[MY IPaddress]

debug1: Found key in /Users/alexschutz/.ssh/known_hosts:5
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /Users/alexschutz/.ssh/id_rsa RSA SHA256:J+VA9pBm3glh6xGB0kMkUs8SAIJ5Wu5G+rvuEkXu23s
debug1: Will attempt key: /Users/alexschutz/.ssh/id_dsa 
debug1: Will attempt key: /Users/alexschutz/.ssh/id_ecdsa 
debug1: Will attempt key: /Users/alexschutz/.ssh/id_ed25519 ED25519 SHA256:uzUMHM4CwXq3FoKswpP/kDCx252621NLmqLTP7YFUUI
debug1: Will attempt key: /Users/alexschutz/.ssh/id_xmss 
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],ssh-dss,ssh-rsa,rsa-sha2-256,rsa-sha2-512>
debug1: kex_input_ext_info: [email protected] (unrecognised)
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/alexschutz/.ssh/id_rsa RSA SHA256:J+VA9pBm3glh6xGB0kMkUs8SAIJ5Wu5G+rvuEkXu23s
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/alexschutz/.ssh/id_dsa
debug1: Trying private key: /Users/alexschutz/.ssh/id_ecdsa
debug1: Offering public key: /Users/alexschutz/.ssh/id_ed25519 ED25519 SHA256:uzUMHM4CwXq3FoKswpP/kDCx252621NLmqLTP7YFUUI
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/alexschutz/.ssh/id_xmss
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

I also get this error:

alexschutz@Alexs-MBP ~ % ssh-copy-id root@[MY IPADDRESS]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/alexschutz/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@[MY IPADDRESS]: Permission denied (publickey).

Not quite sure if conflicting public keys is the issue then.

I was able to ssh into it a few days ago, but I'm not sure what I did to disrupt things since.

1

There are 1 best solutions below

0
Schwern On

Not quite sure if conflicting public keys is the issue then.

There's no such thing as conflicting public keys. Your client offers its private keys one at a time (looks like you have two, id_rsa and id_ed25519) and the server checks if it matches any of its authorized public keys.


One of two things could be wrong. You could be offering the wrong private keys, or you could have added the wrong authorized public keys to the server. Since it was working before, you're probably offering the wrong private keys.

Is it the right key?

By default, ssh will look for a set of files like ~/.ssh/id_something.

debug1: Will attempt key: /Users/alexschutz/.ssh/id_rsa RSA SHA256:J+VA9pBm3glh6xGB0kMkUs8SAIJ5Wu5G+rvuEkXu23s
debug1: Will attempt key: /Users/alexschutz/.ssh/id_dsa 
debug1: Will attempt key: /Users/alexschutz/.ssh/id_ecdsa 
debug1: Will attempt key: /Users/alexschutz/.ssh/id_ed25519 ED25519 SHA256:uzUMHM4CwXq3FoKswpP/kDCx252621NLmqLTP7YFUUI
debug1: Will attempt key: /Users/alexschutz/.ssh/id_xmss 

It's possible earlier you were using a different key. Check inside ~/.ssh/ to see if there's another key pair. It's possible you added the key to your ssh-agent. Since then ssh-agent has forgotten the key, perhaps you rebooted, and you need to add it again.

Reset the key

If that doesn't work...

Log in to your droplet with a password and figure out what's going on. This is currently disabled (ssh did not prompt you for a password). To enable it, see How Recover Access to Droplets using the Recovery Console.

Then you can use ssh-copy-id with a password to get an SSH key onto the droplet. You should then look at ~/.ssh/authorized_keys on your droplet to figure out what went wrong.

You probably copied one of your Digital Ocean public SSH key to the droplet. You can see this in Settings -> Security. Verify the fingerprint matches one of your keys (either id_rsa or id_ed25519). If not, then your key changed (or you lost it) and you should probably fix that by removing this key and adding a fresh one.