Cant ssh into server

I setup a new droplet about 36hrs ago and followed the tutorials here on DO to create the ssh keys for my local computer. I logged out and then back in after to make sure it worked and I must have logged out and back in a few times after that.

Today however when I run ‘ssh myusername@myserverip’ nothing happens, the cursor moves to a new line and just sites there, no error message is given and Im not prompted to do anything else. Ive tried new terminals as well as restarting and still the same. I can see the .ssh folder in my main user directory on my computer (ubuntu) and in that there are the following files

known_hosts my-ssh-key

these all seem to have the keys in too.

What is the problem here?


and this is its status

sudo ufw status Status: active

To Action From

Nginx Full ALLOW Anywhere
Nginx Full (v6) ALLOW Anywhere (v6)

Not much in the -v output to help so here are a couple more things to try.

1.) Disable UFW to make sure it’s not the issue. sudo ufw stop (if this solves the problem don’t forget to come back and fix the configuration since a firewall that isn’t running doesn’t do any good :) ) 2.) Try restarting your ssh service from the console service ssh restart

OK so it is/was ufw, just re-enabled it, logged out and then exact same problem again when I try get back in from local terminal, disabled it again from console and can login again from terminal. Im going to look closer at what I had allowed and disallowed before with ufw now…

thanks, that worked, I did both so not sure which it was that did it, I think maybe the ssh restart as I think recall disabling ufw before at some point.

thanks, this is the -v out put

ssh david@ -v OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to [] port 22.

(edit - I should add that after that last line it just hangs and nothing else happens)

I can ping the server just fine.

I forgot to mention that I can access the server just fine via the console from my account.

I had skipped the ufw setup after initializing the droplet but I went straight to this tutorial which did instruct to run ‘ufw delete allow 8080’ towards the end before enabling ‘Nginx Full’

if you see the last comment there I am actually stuck there too with a 502 bad gateway problem, not sure if this is related though…

There are a few things I would recommend trying in order to start troubleshooting this issue.

1.) add a -v to your ssh command. This will provide more verbose output and might point to the issue.

2.) Use ping/traceroute and make sure you can reach your server. This will help rule out a networking issue.

3.) If you have a password set for your user as well, try logging in via the console in the control panel.

Let us know what you find.

Hi, Are you sure your Droplet is up and could be accessed via Internet? Most easiest way to check it is to ping your Droplet via IP (from your local machine). If Droplet doesn’t answer to ping, it means that Droplet is down or for some reason have network disabled. In case it is ping is successful, you can try restarting whole Droplet or only restarting SSH via Console in Control Panel.

Make sure you didn’t made any other change that can break SSH connection, for example enabling firewall

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

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

From droplet console

sudo ufw disable sudo ufw allow ssh

and try ssh login. After login

sudo ufw enable sudo ufw status

You should see:

Status: active To Action From

Apache Full ALLOW Anywhere 22 ALLOW Anywhere Apache Full (v6) ALLOW Anywhere (v6) 22 (v6) ALLOW Anywhere (v6)

Port 22 is ssh port and it is allowed now.

Monday Sept 10 – just to confirm a simple solution to SSH not working with Firewall

Firewall will not allow SSH login unless the firewall has been set to allow SSH. To set the firewall correctly : login to droplet sudo ufw disable sudo ufw allow ssh sudo ufw enable

The sudo app list does not change. BUT the SSH login (eg via Putty using SSH keys) will then work fine. For me this has only happened with 16.04

Go to your droplet and click on Power on. that worked for me