1

Github Actions runner 通过 SSH 连接到创建的 Droplet。

我的步骤:

  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

✔️ 在 Windows 本地机器上使用 runned from 测试doctl.exe-cmd有效!
✔️ 使用脚本在基于 Linux 映像的 Docker(安装在 Windows)上测试doctl- 有效!
⚠️ 基于 ubuntu-latest 使用digitalocean/action-doctl脚本在 Github Actions 运行器上测试 - 不起作用!

收到的消息是:connect to host ADDRESS_IP port 22: Connection refused

所以步骤是正确的,为什么这对 Github Actions 不起作用?

4

1 回答 1

0

如果您使用的是 GitHub Action digitalocean/action-doctl,请先查看问题 14

为了通过 SSH 连接到 Droplet,doctl 需要访问 SSH 密钥对的私有部分,其公共部分在 Droplet 上。
目前,doctl Action 是基于 Docker 容器的。

如果你直接使用 Docker 容器,你可以调用它:

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>

为了从容器外部挂载 SSH 密钥。

您最好只使用doctlgrep Droplet 的 IP 地址并使用这个更专注于 SSH 相关用例并提供许多附加功能的操作:marketplace/actions/ssh-remote-commands.

于 2021-03-28T02:44:31.420 回答