我无法从实例复制文件,尤其是复制到实例。我在实例中创建了 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].
编写完整路径有效:
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%
为什么 ~/ 不起作用?文档示例使用它,不应该是一样的吗?看:
stefan_pochmann_gmail_com@instance-4:~$ cd ~/
stefan_pochmann_gmail_com@instance-4:~$ pwd
/home/stefan_pochmann_gmail_com
另一个方向根本不起作用(?):
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].
为什么权限被拒绝?好的,我尝试 ~/ 而不是写完整路径:
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/ 中。但我不知道,因为我不得不使用 ~/ 这在下载方向上根本不起作用。我怎样才能让它工作?