1

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

✔️ Tested on Windows local machine using doctl.exe runned from cmd - works!
✔️ Tested on Docker (installed on Windows) based on Linux image using doctl script - works!
⚠️ 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?

kicaj
  • 2,881
  • 5
  • 42
  • 68

1 Answers1

0

If you are using the GitHub Action digitalocean/action-doctl, check issue 14 first:

In order to SSH into a Droplet, doctl needs access to the private half of the SSH key pair whose public half is on the Droplet.
Currently the doctl Action is based on a Docker container.

If you were using the Docker container directly, you could invoke it with:

docker run --rm --interactive --tty \
 --env=DIGITALOCEAN_ACCESS_TOKEN=<YOUR-DO-API-TOKEN> \
 -v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa \
 digitalocean/doctl compute ssh <DROPLET-ID>

in order to mount the SSH key from outside the container.

You might be better off just using doctl to grep the Droplet's IP address and using this Action that is more focused on SSH related use cases and provides a lot of additional functionality: marketplace/actions/ssh-remote-commands.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250