Matthew Burkhardt
Matthew Burkhardt

Reputation: 1

Why am I unable to run `ssh-keygen` from Google Cloud Function?

I'm trying to ssh from a Google Cloud Function into a Google Compute VM using the following: How to SSH from Cloud Functions to a GCE Instance

When I test the code in the GCF Testing environment, I get the following error:

No such file or directory: 'ssh-keygen'

I can run ssh-keygen from the Cloud Shell Terminal directly, but it won't run when being invoked from inside the subprocess command in Python.

Upvotes: 0

Views: 41

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 76063

Cloud Functions is a service that takes your code, packages it in a standard container and deploys it on the service.

The problem here is that the container base image is standard, and you make the assumption that ssh-keygen is pre-installed on it. Which is obviously wrong.

The solution here is to have a better control on the container creation and the binaries installed on it. For that, you can use Cloud Run where you package your code in a container yourselves, and therefore you can install whatever you want on it.

Upvotes: 0

Related Questions