У меня очень много времени на то, чтобы моя учетная запись службы Google подключилась к нашему экземпляру Compute Engine по ssh из конвейеров битбакета.
Script:
gcloud compute ssh instance1 --zone us-central1-a --quiet --verbosity=info --command="gracefully shutdown processes" && \
gcloud compute scp ~/ instance1:~/ --zone us-central1-a --quiet --recurse --compress && \
gcloud compute ssh instance1 --zone us-central1-a --quiet --verbosity=info --command="start the services"
ERROR: (gcloud.compute.ssh) Could not SSH into the instance. It is possible that your SSH key has not propagated to the instance yet. Try running this command again. If you still cannot connect, verify that the firewall and instance are set to accept ssh traffic.
Permission denied (publickey).
lost connection
ERROR: (gcloud.compute.scp) [/usr/bin/scp] exited with return code [1].
Я даже пробовал старомодный способ SSHing без gcloud. Я добавил открытый ключ к экземпляру, используя metadata
. Я могу подключиться по SSH на моем локальном компьютере, но с конвейерами битбакета я получаю ошибку отказа в разрешении.
script:
- echo $PRIVATE_SSH_KEY > ./ssh_key
- chmod 400 ssh_key
- ssh -t -t -i ssh_key bitbucket-service-account@<IP>
Permission denied (publickey).
Что я мог делать не так?