gcloud计算副本文件实例目的地?

Ste*_*ann 3 upload gcloud

我无法从实例复制文件,特别是复制到实例.我在实例中创建了instance.txt(使用SSH),这不起作用:

C:\test>gcloud compute copy-files instance-4:~/instance.txt . --zone us-central1-b
Passphrase for key "censoredbyme":
unable to identify instance.txt: no such file or directory
ERROR: (gcloud.compute.copy-files) [C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin\..\bin\sdk\scp.EXE] exited with return code [1].
Run Code Online (Sandbox Code Playgroud)

编写完整路径有效:

C:\test>gcloud compute copy-files instance-4:/home/stefan_pochmann_gmail_com/instance.txt . --zone us-central1-b
Passphrase for key "censoredbyme":
instance.txt              | 0 kB |   0.0 kB/s | ETA: 00:00:00 | 100%
Run Code Online (Sandbox Code Playgroud)

为什么〜/不起作用?文档示例使用它,它不应该是相同的吗?看到:

stefan_pochmann_gmail_com@instance-4:~$ cd ~/
stefan_pochmann_gmail_com@instance-4:~$ pwd
/home/stefan_pochmann_gmail_com
Run Code Online (Sandbox Code Playgroud)

另一个方向根本不起作用(?):

C:\test>gcloud compute copy-files local.txt instance-4:/home/stefan_pochmann_gmail_com --zone us-central1-b
Passphrase for key "censoredbyme":
scp: unable to open /home/stefan_pochmann_gmail_com/local.txt: permission denied
ERROR: (gcloud.compute.copy-files) [C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin\..\bin\sdk\scp.EXE] exited with return code [1].

C:\test>gcloud compute copy-files local.txt instance-4:/home/stefan_pochmann_gmail_com/ --zone us-central1-b
Passphrase for key "censoredbyme":
scp: unable to open /home/stefan_pochmann_gmail_com//local.txt: permission denied
ERROR: (gcloud.compute.copy-files) [C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin\..\bin\sdk\scp.EXE] exited with return code [1].
Run Code Online (Sandbox Code Playgroud)

为何拒绝许可?好吧,我尝试〜/而不是写完整的路径:

C:\test>gcloud compute copy-files local.txt instance-4:~/ --zone us-central1-b
Passphrase for key "censoredbyme":
local.txt                 | 0 kB |   0.0 kB/s | ETA: 00:00:00 | 100%
Run Code Online (Sandbox Code Playgroud)

看起来像它上传的文件,但该文件不存在.至少不在/ home/stefan_pochmann_gmail_com /我期待的地方.但我不知道因为我必须使用〜/在下载方向根本不起作用.我如何让它工作?

Adr*_*ián 5

在这种情况下,Google Cloud SDK正在按预期工作.

当您gcloud compute第一次尝试使用命令时,它会告诉您" 您没有Google Compute Engine的SSH密钥 ",它会创建私钥,公钥(.pub)和PuTTY格式密钥(.ppk)通常在C:\Users\<username>\.ssh\目录中(它可能在不同的Windows版本之间有所不同).

如果您打开google_compute_engine.pub文件,最后您将找到用于访问实例的用户名.此用户名与您在执行gcloud命令时记录的本地用户名相匹配.

如果要运行gcloud compute copy-files instance-4:~/instance.txt . --zone us-central1-b,可以按照以下步骤操作:1-转到开发人员控制台 - >选择项目 - >计算 - >计算引擎 - >元数据 - > SSH密钥 - >编辑和修改SSH密钥,其中出现Stefan stefan_pochmann_gmail_com在关键内容的末尾左键输入而不是Stefan.

  • 如果是这样的话,那么bug就在文档中.谁的本地名称与其默认gce名称相匹配?我猜几乎没有人.[计算页面](https://cloud.google.com/compute/docs/gcloud-compute/#connecting)(我来自哪里)完全忽略了这个问题,甚至[copy-files page](https: //cloud.google.com/sdk/gcloud/reference/compute/copy-files)没有谈论它,只显示技术完整语法中的用户名选项. (3认同)
  • 创建新项目然后创建第一个实例时,不会创建用户.然后,您有3种方法来创建用户:1-使用命令`gcloud compute ssh <instance>`2-创建SSH密钥并在项目元数据中手动添加3-单击"SSH"按钮即可在开发人员控制台中查找.#1和#2将创建一个与本地计算机中的用户匹配的用户.但是,#3将创建一个用户,该用户与您在开发人员控制台中登录时使用的电子邮件地址相匹配,因为您的浏览器不知道您的计算机的用户名. (3认同)