在两个Google Cloud实例之间复制文件 [英] Copy files between two Google Cloud instances

查看:87
本文介绍了在两个Google Cloud实例之间复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google Cloud中有两个项目,我需要将文件从一个项目中的一个实例复制到另一个项目中的一个实例.我尝试使用"gcloud compute copy-files"命令,但出现此错误:

I have two projects in Google Cloud and I need to copy files from an instance in one project to an instance in another project. I tried to using the 'gcloud compute copy-files' command but I'm getting this error:

gcloud compute copy-files test.tgz --project stack-complete-343 instance-IP:/home/ubuntu --zone us-central1-a 

ERROR: (gcloud.compute.copy-files) Could not fetch instance: - Insufficient Permission

推荐答案

我能够使用全新的VM实例复制您的问题,并得到相同的错误.以下是我为纠正该问题而采取的一些步骤:

I was able to replicate your issue with a brand new VM instance, getting the same error. Here are a few steps that I took to correct the problem:

确保您已通过身份验证,并拥有使用同一帐户访问两个项目的权限!

Make sure you are authenticated and have rights to both projects with the same account!

$ gcloud config list(如果看到服务帐户@ developer.gserviceaccount.com,则需要切换到两个项目都启用的帐户.可以从Devlopers Console>权限中进行检查)

$ gcloud config list (if you see the service account @developer.gserviceaccount.com, you need to switch to the account that is enabled on both projects. you can check that from the Devlopers Console > Permissions)

$ gcloud auth login(将链接复制到新窗口,登录,复制代码并将其粘贴回提示符)

$ gcloud auth login (copy the link to a new window, login, copy the code and paste it back in the prompt)

$ gcloud compute copy-files test.tgz --project stack-complete-343 instance-IP:/home/ubuntu --zone us-central1-a(我也将使用实例名称代替IP)

$ gcloud compute copy-files test.tgz --project stack-complete-343 instance-IP:/home/ubuntu --zone us-central1-a (I would also use the instance name instead of the IP)

最后一条命令还应该生成您的ssh密钥.您应该会看到类似这样的内容,但是不必担心输入密码:

This last command should also generate your ssh keys. You should see something like this, but do not worry about entering a passphrase :

警告:[/usr/bin/ssh-keygen]将被执行以生成密钥.

WARNING: [/usr/bin/ssh-keygen] will be executed to generate a key.

生成公共/私有rsa密钥对

Generating public/private rsa key pair

输入密码(无密码时为空):

Enter passphrase (empty for no passphrase):

这篇关于在两个Google Cloud实例之间复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆