我无法从实例复制文件,特别是复制到实例.我在实例中创建了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 /我期待的地方.但我不知道因为我必须使用〜/在下载方向根本不起作用.我如何让它工作?
在这种情况下,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.
| 归档时间: |
|
| 查看次数: |
7206 次 |
| 最近记录: |