Can't connect with ssh from OSX or Ubuntu 14.04

August 16, 2014 7.2k views

I have a new 1GB droplet on Ubuntu 14.04 x64 that I am trying to connect to with ssh. So far I have been unsuccessful.

I was trying to connect earlier today from the terminal in OSX but I wasn’t able to get passed an error. I don’t have access to that computer at the moment butssh -v root@[my server ip] ended with something like:

debug1: Local version string SSH-2.0-OpenSSH_6.2
ssh_exchange_identification: read: Connection reset by server

After I got home I tried connecting with the terminal on my home computer running Ubuntu 14.04 but still had no luck. It always results in Connection closed by [my server ip].

The more detailed response from ssh -vvvv root@[my server ip] results in:

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to [my server ip] [my server ip] port 22.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/twalters/.ssh/id_rsa" as a RSA1 public key
debug1: identity file /home/twalters/.ssh/id_rsa type 1
debug1: identity file /home/twalters/.ssh/id_rsa-cert type -1
debug1: identity file /home/twalters/.ssh/id_dsa type -1
debug1: identity file /home/twalters/.ssh/id_dsa-cert type -1
debug1: identity file /home/twalters/.ssh/id_ecdsa type -1
debug1: identity file /home/twalters/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/twalters/.ssh/id_ed25519 type -1
debug1: identity file /home/twalters/.ssh/id_ed25519-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 OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "[my server ip]" from file "/home/twalters/.ssh/known_hosts"
debug3: load_hostkeys: loaded 0 keys
debug1: SSH2_MSG_KEXINIT sent
Connection closed by [my server ip]

I confirmed that id_rsa.pub on my home system matches ~/.ssh/authorized_keys.

2 Answers

Well, I am not sure exactly what I did that worked but I erased my ssh key and generated a new one. Then I destroyed my droplet and added a new one with my new ssh key. Now everything works.

I had already tried destroying the droplet and starting over without success so the problem must have been with the ssh key on my computer I guess.

Got in the same situation. Here’s what I did.

1) Delete your droplet
2) Delete your saved ssh key (both on DigitalOcean[1] and on your own computer[2]), and start over using their guide: https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets
3) Create a droplet––but remember! Check the box to use your new ssh key before you create the droplet!

That’s it. Go to your own terminal and try to login using:
$ ssh root@<your.ip.here>

Everything should be gravy.

[1] Delete your ssh key here: https://cloud.digitalocean.com/settings/security
[2] Own your personal computer, delete your files in ~/.ssh. You don’t have to delete the .ssh folder itself.

by Etel Sverdlov
This guide is for Mac OS X and Linux users. Learn how to use SSH Keys with DigitalOcean Droplets.
Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!