使用gcloud

时间:2018-09-08 12:25:34

标签: bitbucket google-compute-engine gcloud bitbucket-pipelines

我正在使用Bitbucket管道在计算引擎上的可抢占机器上运行部署脚本。我使用具有所有者角色的google sdk和服务帐户,但仍然无法SSH到计算机。 这就是我的bitbucket-pipelines.yml的样子:

- echo $GCLOUD_API_KEYFILE | base64 --decode --ignore-garbage > ./gcloud-api-key.json
- gcloud auth activate-service-account --key-file gcloud-api-key.json
- gcloud config set project $GCLOUD_PROJECT
- gcloud compute --project $GCLOUD_PROJECT ssh --zone "us-east1-c" $INSTANCE_NAME --command "./deploy"

我看到我能够成功进行身份验证:

Activated service account credentials for: [...]

但是我仍然无法通过ssh实例化

    gcloud compute --project "..." ssh --zone "us-east1-c" "..." --command "..."
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: ...
...
Updating project ssh metadata...
................Updated [https://www.googleapis.com/compute/v1/projects/...].
done.
Waiting for SSH key to propagate.
Warning: Permanently added '...' (RSA) to the list of known hosts.
Permission denied (publickey).

我想念什么吗?我的理解是,一旦我通过具有权限的服务帐户身份验证执行ssh,gcloud ssh命令就可以正常工作

1 个答案:

答案 0 :(得分:1)

  • 这是一个基本的SSH问题,
  • 请检查该线程[1]。

[1] How to get the ssh keys for a new Google Compute Engine instance?