Search code examples
sshgoogle-cloud-platformcontinuous-deliverycircleci-2.0

How do I ssh into a GCP compute engine instance from circleci?


I'm using circleci 2.0 and I'm trying to have circleci enter a gcp instance via ssh and fire off a deployment script with this command

sudo /opt/google-cloud-sdk/bin/gcloud compute ssh instance-1 
--command=/home/deploy_staging.sh --zone=us-east1-b

Doing this from my local machine works just fine, but when I try to do it from circleci I get this error:

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)

Obviously it's ssh issues. I read something about putting ssh keys in the instance on gcp, and I have put my local machine's ssh keys there, but that still doesn't work.


Solution

  • According to the official CircleCI documentation, you first need to add the SSH key for the server in the CircleCI application - this can be done on your project’s settings and under the SSH Permissions section.