`gcloud compute copy-files`: permission denied when copying files

前端 未结 7 1925
滥情空心
滥情空心 2020-12-04 22:24

I\'m having a hard time copying files over to my Google Compute Engine. I am using an Ubuntu server on Google Compute Engine.

I\'m doing this from my OS X terminal a

相关标签:
7条回答
  • 2020-12-04 22:54

    The updated solution for this exact issue (2020)

    For the sake of exposition, we have to break the issue in two parts. The "copy-files" command is officially depreciated and we are to use "scp", however both old and new options are limited to certain folders only.

    Since we do have access to the /tmp folder, this means we can easily move our distribution files with the preferred "scp" command, as a staging step.

    More importantly we also have access to execute scripts, or commands remotely via SSH on the instance which means the limited access is no longer an issue.

    Example Time

    The first part is to copy the dist folder, and all it's content recursively to the tmp folder to which gloud does give access:

    gcloud compute scp --recurse dist user_name@instance:/tmp

    The second part leverages the fact that we can run commands remotely via ssh:

    gcloud compute ssh user_name@instance --command "sudo bash golive"

    (or any other command you may need to execute)

    More importantly this also means that we can just copy our distribution files to the final destination using sudo and the "cp" copy function:

    gcloud compute ssh user_name@instance --command "sudo cp -rlf /tmp/dist/* /var/www/html/"

    This completely eliminates the need to set the permissions first through the ssh terminal.

    0 讨论(0)
提交回复
热议问题