![无法从 google/cloud-sdk:alpine docker 容器通过 ssh 连接到 gcloud VM 实例](https://linux22.com/image/719972/%E6%97%A0%E6%B3%95%E4%BB%8E%20google%2Fcloud-sdk%3Aalpine%20docker%20%E5%AE%B9%E5%99%A8%E9%80%9A%E8%BF%87%20ssh%20%E8%BF%9E%E6%8E%A5%E5%88%B0%20gcloud%20VM%20%E5%AE%9E%E4%BE%8B.png)
我正在尝试从 GitLab CI/CD 运行器连接到 Google Cloud VM 实例,以便能够部署 Docker Swarm 堆栈和服务。但是我发现在运行时
gcloud compute ssh <instance-name> --quiet
从 google/cloud-sdk:alpine docker 镜像中,密钥已上传到镜像中(使用云控制台确认),但连接失败
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].
使用 -vvv 检查输出时,输出的最后几行显示
debug1: Offering RSA public key: /root/.ssh/google_compute_engine
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp SHA256:pbWpf3dF2nJgcR9Z7pPmIwTsS0IEKK5bgakYJfAQK5o
debug3: sign_and_send_pubkey: RSA SHA256:pbWpf3dF2nJgcR9Z7pPmIwTsS0IEKK5bgakYJfAQK5o
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
使用云控制台中的 SSH 按钮连接工作正常。
有什么想法可能阻止这项工作吗?
答案1
经过一些实验,结果表明以不同的用户身份登录 root 是可行的,即使用
gcloud compute ssh <user-name>@<instance-name> --quiet
一切正常。我猜想 Google 不允许 root ssh 访问其实例。