Connection to remote server via SSH return Connection refused

Connection to created Droplet via SSH by Github Actions runner.

My steps:

  1. ssh-keygen -t rsa -f ~/.ssh/KEY_NAME -P ""
  2. doctl compute ssh-key create KEY --public-key "CONTENT OF KEY_NAME.pub"
  3. doctl compute droplet create --image ubuntu-20-04-x64 --size s-1vcpu-1gb --region fra1 DROPLET_NAME --ssh-keys FINGERPRINT --wait
  4. ssh -vvv -i ~/.ssh/KEY_NAME root@DROPLET_IP

:heavy_check_mark: Tested on Windows local machine using doctl.exe runned from cmd - works!
:heavy_check_mark: Tested on Docker (installed on Windows) based on Linux image using doctl script - works!
:warning: Tested on Github Actions runner based on ubuntu-latest using digitalocean/action-doctl script - doesn’t work!

Received message is: connect to host ADDRESS_IP port 22: Connection refused .

So the steps are correct, so why does this not work for Github Actions?

1 Like

I have two guesses here:

  1. It might be that running this automatically (instead of manually command for command) is simply too fast, and the SSH server isn’t up yet when step 4 runs. You could try repeating the connection a few times (best wait a few seconds between tries), if it works after a little while that was probably the problem.

  2. Could there be a firewall that blocks connections from the GitHub runner? I’m not familiar with the DO infrastructure, so I can’t say how to check.