我正在使用circleci 2.0而我正在尝试让circleci通过ssh进入gcp实例并使用此命令触发部署脚本
sudo /opt/google-cloud-sdk/bin/gcloud compute ssh instance-1
--command=/home/deploy_staging.sh --zone=us-east1-b
从我的本地机器上执行此操作很好,但是当我尝试从circleci执行此操作时,我收到此错误:
WARNING: The public SSH key file for gcloud does not exist.
WARNING: The private SSH key file for gcloud does not exist.
WARNING: You do not have an SSH key for gcloud.
WARNING: SSH keygen will be executed to generate a key.
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Too long with no output (exceeded 10m0s)
显然这是ssh问题。我读了一些关于在gcp上将ssh密钥放在实例中的内容,并且我已将我的本地机器的ssh密钥放在那里,但这仍然无效。
答案 0 :(得分:0)
根据official CircleCI documentation,您首先需要在CircleCI应用程序中添加服务器的SSH密钥-可以在您的项目设置和“ SSH权限”部分下完成此操作。
答案 1 :(得分:0)
gcloud \
--quiet \
--project="${PROJECT}" \
compute ssh "${INSTANCE_NAME}" \
--zone "${ZONE}" \
--strict-host-key-checking=no \
--command "echo works"
--quiet
是您所需要的,如果没有密钥,它将生成一个密钥。我正在通过服务帐户使用它。
WARNING: The public SSH key file for gcloud does not exist.
WARNING: The private SSH key file for gcloud does not exist.
WARNING: You do not have an SSH key for gcloud.
WARNING: SSH keygen will be executed to generate a key.
Generating public/private rsa key pair.
Your identification has been saved in /root/.ssh/google_compute_engine.
Your public key has been saved in /root/.ssh/google_compute_engine.pub.
The key fingerprint is:
SHA256:un2aZmExTGVD0KvebEVqAujrlXoAb0u7jO3Z5boCWaA root@581dc589b7fa
The key's randomart image is:
+---[RSA 2048]----+
| .== |
| . .... |
| . . . o . |
|E . o . + . . |
| * .S+ o |
| o * o= o . |
| + =+o.* . |
| +==.=+.= |
| .oO+===+ |
+----[SHA256]-----+
WARNING: Using OS Login user [sa_102839341411404994442] instead of default user [root]