I was following along with this tutorial: https://cloud.google.com/community/tutorials/setting-up-lamp

and I wanted to upload a php file to my instance to run, using the following command:

gcloud compute scp [LOCAL_FILE_PATH] lamp-tutorial:/var/www/html

but I got the following:

enter image description here

What went wrong? And how could I transfer files to my instance?


You have to run these commands on your local computer that contains the files you want to send to the virtual machine, not the Cloud Shell, or the remote virtual machine itself.


There are many ways to transfer files to GCP vm instances, the one that I like is using native function to upload files, to use it, in your GCP console go to your instance, click SSH button and in the top right corner of the SSH window you will see a gear, click it and there is an option called “upload file,” that will open a menu where you can browse your local drive(s) and choose the file which you want to upload, click upload button and that’s it. Here you can consult Google documentation about this process.

However if you’re interested in transfer files using gcloud commands from your workstation, it is necessary to install Cloud SDK and configure it to interact with your project and instances, in order to perform that task you can visit this page which contains all the information that you need to start, in this menu you can find the official GCP software for your OS and a full starter guide.

Finally, the command that you’re running must be execute from your local machine using SDK tools, or in cloud shell, to open cloud shell, look in the top right corner of your GCP console the icon with this symbols “>_” click it, and you will see the cloud shell, nevertheless before transfer any file to your instance using cloud shell it is necessary to upload the file to your project, this process is similar to the first that I described, this document can help to clarify the process.

Hope this information will be useful for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.