guillaume blaquiere
Nov 12 · 1 min read

Ok. I tested deeper and forget the sleep 15. It’s true for script, but not in this terraform & cloud build context.

The problem is tricky. With the verbosity debug, you can see this trace

DEBUG: Executing command: [u'/usr/bin/ssh', u'-T', u'-i', u'/builder/home/.ssh/google_compute_engine', u'-o', u'CheckHostIP=no', u'-o', u'HostKeyAlias=compute.7953677305751525032', u'-o', u'IdentitiesOnly=yes', u'-o', u'StrictHostKeyChecking=no', u'-o', u'UserKnownHostsFile=/builder/home/.ssh/google_compute_known_hosts', u'root@35.223.85.55', u'--', u'true']
Failed to add the host to the list of known hosts (/builder/home/.ssh/google_compute_known_hosts).
Permission denied (publickey).

Lot of boring things to read, I put in bold the problem: Cloud Build has no specific user and use root to connect to the VM. For security reason, it’s not possible.

For solving this, set a dummy (change this by what you want, except root) user in your scp line

gcloud compute scp a.txt dummy@deleteme-vm6:/tmp ...

Tell me if it’s OK now.

PS: Your tf file and your cloudbuild.yaml file are desynchronized in the vm name.

    guillaume blaquiere

    Written by

    Team leader, scrum master, speaker, writer and polyglot developer, Google Cloud platform certified, serverless addict and Go fan.

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade