首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gcloud计算复制文件的实例目的地?

gcloud计算复制文件的实例目的地?
EN

Stack Overflow用户
提问于 2014-11-06 09:08:40
回答 3查看 8.5K关注 0票数 3

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

代码语言:javascript
复制
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].

编写完整路径是可行的:

代码语言:javascript
复制
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%

为什么不起作用?文档示例使用它,难道不应该是相同的吗?请参见:

代码语言:javascript
复制
stefan_pochmann_gmail_com@instance-4:~$ cd ~/
stefan_pochmann_gmail_com@instance-4:~$ pwd
/home/stefan_pochmann_gmail_com

另一个方向根本行不通(?):

代码语言:javascript
复制
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].

为什么拒绝许可?好的,我尝试~/而不是写完整的路径:

代码语言:javascript
复制
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%

看起来它上传了文件,但文件不在那里。至少不是在/home/stefan_pochmann_gmail_com/我期望的地方。但是我不知道,因为我不得不使用~/它在下载方向上根本不起作用。我怎么才能让这个起作用?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-11-18 15:29:10

在这种情况下,正在按预期工作。

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

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

如果您想运行gcloud compute copy-files instance-4:~/instance.txt . --zone us-central1-b,您可以执行接下来的步骤: 1-转到开发人员控制台->,选择您的项目-> Compute-> Compute ->元数据->编辑,并修改显示Stefan在左键stefan_pochmann_gmail_com而不是Stefan在键内容末尾的SSH键。

票数 5
EN

Stack Overflow用户

发布于 2014-11-06 09:26:32

好吧我刚解决了。我的本地帐户是"Stefan",gcloud使用了/home/Stefan作为实例(bug?)。这解释了错误,上传的文件最终变成/home/Stefan/local.txt (with /home/Stefan及其中的所有内容由新创建的用户"Stefan“拥有)。我不得不用sudo删除它)。在实例名称之前添加"stefan_pochmann_gmail_com@“。

票数 4
EN

Stack Overflow用户

发布于 2017-11-22 19:20:09

如果您想将文件从本地机器复制到gcloud实例(gcloud)

然后使用以下命令:

gcloud compute scp [file location] [user]@[instance]:~/[location] --zone [zone name]

例如:

gcloud compute scp ~/Documents/hello.txt john@linux:~/MyFiles --zone us-east1-b

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26775492

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档