Bad Coder
Bad Coder

Reputation: 906

GCP Copying File from my local Machine to GCP Vm

I am copying my file from my local machine to Google VM machine.

I currently accessing Google VM using my local machine SSH connection

Following is the command:

gcloud compute scp ~/Desktop/testing.png  dms-2:~/testing --internal-ip --zone=us-west1-b

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    19  100    19    0     0   2100      0 --:--:-- --:--:-- --:--:--  2375
testing.png                                                                                                                                                               100%  133KB  19.1KB/s   00:06 

But when i doing ls on my Google VM nothing comes up :

s0p04bp@dms-2:~$ cd /usr/lib/testing/
s0p04bp@dms-2:/usr/lib/testing$ ls
s0p04bp@dms-2:/usr/lib/testing$ pwd
/usr/lib/testing
s0p04bp@dms-2:/usr/lib/testing$ 

Not sure why it's not showing it in my google VM ?

Upvotes: 1

Views: 3292

Answers (1)

Amir Rahwane
Amir Rahwane

Reputation: 674

It looks like you are copying the file to the wrong directory.

The tilde (~) is a Linux "shortcut" to denote a user's home directory. Thus tilde slash (~/) is the beginning of a path to a file or directory below the user's home directory.

From: https://twiki.org/cgi-bin/view/Wikilearn/TildeSlash

If you want testing.png to appear inside the directory /usr/lib/testing/, ending up as /usr/lib/testing/testing.png you should copy it there. I would also be specific about the user I connect as to the GCP instance.

The next example will work assuming /usr/lib/testing/ folder exists on the remote instance and has the right permissions. Since /usr/lib is usually editable by root user alone.

gcloud compute scp ~/Desktop/testing.png  s0p04bp@dms-2:/usr/lib/testing/ --zone=us-west1-b

If the folder does not exist, you will need to create it first and give it the right permissions.

gcloud compute ssh s0p04bp@dms-2 zone=us-west1-b --command "sudo mkdir -p /usr/lib/testing && sudo chown s0p04bp:s0p04bp /usr/lib/testing"

Upvotes: 2

Related Questions