为什么我无法从 Google Cloud Function 运行 `ssh-keygen`?

问题描述 投票:0回答:1

我正在尝试使用以下命令从 Google Cloud Function

ssh
进入 Google Compute VM: 如何从 Cloud Functions SSH 到 GCE 实例

当我在GCF测试环境中测试代码时,出现以下错误:

没有这样的文件或目录:'ssh-keygen'

我可以直接从 Cloud Shell 终端运行

ssh-keygen
,但从 Python 中的子进程命令内部调用时它不会运行。

google-cloud-platform google-cloud-functions subprocess ssh-keygen
1个回答
0
投票

Cloud Functions 是一项服务,它获取您的代码,将其打包在标准容器中并将其部署到服务上。

这里的问题是容器基础镜像是标准的,并且您假设 ssh-keygen 已预先安装在其上。这显然是错误的。

这里的解决方案是更好地控制容器的创建及其上安装的二进制文件。为此,您可以使用 Cloud Run,将代码自行打包到容器中,因此您可以在其上安装任何您想要的内容。

© www.soinside.com 2019 - 2024. All rights reserved.