Question

Droplet connection refused using Windows SSH

I have had a droplet for many months. Today I tried using the same SSH command in a Windows command prompt window that has worked in the past and I get:

ssh: connect to host droplet port 22: Connection refused

I can launch a Droplet Console from within DigitalOcean. The droplet is working and connects that way.

The following is the result of service ssh status.

ssh.service - OpenBSD Secure Shell server Loaded: loaded (/usr/lib/systemd/system/ssh.service; disabled; preset: enabled) Active: active (running) since Sat 2024-10-05 23:40:15 UTC; 20s ago TriggeredBy: ● ssh.socket Docs: man:sshd(8) man:sshd_config(5) Process: 15739 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS) Main PID: 15742 (sshd) Tasks: 1 (limit: 2353) Memory: 1.2M (peak: 1.4M) CPU: 32ms CGroup: /system.slice/ssh.service └─15742 “sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups”

Oct 05 23:40:15 ubuntu-vanilla systemd[1]: Starting ssh.service - OpenBSD Secure Shell server… Oct 05 23:40:15 ubuntu-vanilla sshd[15742]: Server listening on :: port 22. Oct 05 23:40:15 ubuntu-vanilla systemd[1]: Started ssh.service - OpenBSD Secure Shell server.

I have read articles and documentation indicating that Ubuntu is using SSH differently but I do not understand what to do about that if that is the problem.

I am using 24.04.1 LTS. The problem existed prior to a Linux version update and after the update.

How can I again use a Windows SSH command to log into the Droplet?


Submit an answer


This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Accepted Answer

I have determined that it is not a problem with the Droplet or DigitalOcean.

KFSys
Site Moderator
Site Moderator badge
October 7, 2024

Heya,

Your ssh service is running fine given the details you’ve posted.

What I’ll recommend is to allow your IP address in your firewall. It seems like it that would be causing the issues. Another alternative would be to allow port 22 through your firewall however I would recommend just allowing your IP address.

Running the following command

sudo ufw allow from XXX.XXX.XXX.XXX

where XXX.XXX.XXX.XXX is your own IP address should do the trick.

Bobby Iliev
Site Moderator
Site Moderator badge
October 6, 2024

Hey Sam! 👋

It looks like your SSH service is running fine based on the service ssh status output, but the “Connection refused” error usually indicates that there might be some network-related issues or firewall rules preventing the connection.

If you have a firewall like ufw enabled on your Droplet, it might be blocking port 22 (which is used for SSH). To check the current status of ufw and allow SSH connections, run the following commands:

sudo ufw status

If you see that port 22 is blocked, you can allow SSH by running:

sudo ufw allow 22/tcp
sudo ufw reload

If you’re using DigitalOcean Cloud Firewalls, make sure that SSH (port 22) is allowed for inbound connections. You can manage firewall rules from the DigitalOcean Control Panel.

If you don’t have a firewall, it’s also worth verifying that your SSH service is configured properly. Check the SSH configuration file:

sudo nano /etc/ssh/sshd_config

Ensure the following lines are uncommented and properly set:

Port 22
PermitRootLogin yes   # or no if you're logging in with a non-root user
PasswordAuthentication yes  # Ensure this is enabled if you're using password-based login

After making any changes, restart the SSH service:

sudo systemctl restart ssh

Recently I had a chat with a user who had the same exact problem and in the end it turned out that they were using the wrong IP address. So I will recommend to make sure you’re using the correct IP address for your Droplet. Sometimes the public IP can change if the Droplet is restarted. You can verify the IP in the Droplets section of the DigitalOcean dashboard and make sure that you are using the public IP address!

Let me know how it goes! If you’re still running into issues, feel free to share any new error messages or logs.

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.