i tried to ssh root@ipaddress. I received error port 22 connection refused. Can you help with this?

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.

×
3 answers

Hi @stanhao

Have you changed the port of the SSH server? If yes, then you need to change on the client too, meaning connecting with -p like:
ssh -p 22 root@domain_or_ip

Maybe you activated the firewall, but forgot to allow port 22?
This means you’re locked out. You can go to the control panel of DigitalOcean and access your droplets console, where you can allow port 22 thru the firewall with this command:
sudo ufw allow 22

Or you have a IPS like fail2ban, which has blocked you for some reason. Go to the console and restart fail2ban, which normally clears any blocking:
service fail2ban restart

@stanhao

To login via SSH, you’ll need to get your Droplet’s Public IPv4 address from the DigitalOcean Control Panel. You’d then login using either:

ssh root@droplet_ip

or, if you’re using SSH Keys:

ssh root@droplet_ip -i /path/to/private_key

Where /path/to/private_key is the direct path to the private key that’s associated with the public key that should be in ~/.ssh/authorized_keys on your Droplet.

The above works if your on a Mac or Linux box using Terminal or another similar application. If you’re on Windows, you’ll need to use PuTTy or something similar and create a session as PuTTy doesn’t work like a standard Terminal application does (in terms of how you login) – at least not the GUI version.

resolved. ssh was not installed correctly

apt-get install openssh-server openssh-client

Submit an Answer