machine icon indicating copy to clipboard operation
machine copied to clipboard

docker-machine scp Permission denied

Open AlexZeitler opened this issue 9 years ago • 11 comments
trafficstars

I created a folder on a Docker machine (default) like this:

docker-machine ssh default -- mkdir -p /home/alexzeitler/src/myproject/subproject

Then I tried to copy local files from the current directory into it:

docker-machine scp -r . default:/home/alexzeitler/src/myproject/subproject

This results in:

scp: /home/alexzeitler/src/myproject/subproject/./config.json: Permission denied
scp: /home/alexzeitler/src/myproject/subproject/./node_modules: Permission denied
scp: /home/alexzeitler/src/myproject/subproject/./.gitignore: Permission denied
scp: /home/alexzeitler/src/myproject/subproject/./docker-compose.yml: Permission denied
scp: /home/alexzeitler/src/myproject/subproject/./api: Permission denied
scp: /home/alexzeitler/src/myproject/subproject/./app.js: Permission denied

AlexZeitler avatar Jan 02 '16 17:01 AlexZeitler

I had to regenerate the certs (because of https://github.com/docker/machine/issues/1954 on Ubuntu as well) - might this cause the problem?

After re-creating the VM the issue is gone.

AlexZeitler avatar Jan 02 '16 17:01 AlexZeitler

Regeneration of certs doesn't seem to cause it. Created another directory and tried to scp into it and it failed again.

AlexZeitler avatar Jan 02 '16 17:01 AlexZeitler

Hi @AlexZeitler, can you tell us which version of docker-machine you are using and which OS you are on? Also if you are not using 0.5.5 of docker-machine, can you please try it?

dgageot avatar Jan 04 '16 11:01 dgageot

@dgageot Thanks for your reply. I'm running on Ubuntu 14.04 x64, docker-machine version 0.5.5, build 02c4254

AlexZeitler avatar Jan 04 '16 12:01 AlexZeitler

This problem is incredibly limiting. I can't put a file on my docker machine!

rjurney avatar Apr 25 '16 19:04 rjurney

@rjurney You might want to try rsync as I described here: https://alexanderzeitler.com/articles/docker-machine-and-docker-compose-developer-workflows/

AlexZeitler avatar Apr 25 '16 20:04 AlexZeitler

In my case, this had to do with filesystem permissions on my boot2docker instance. I worked around it like so:

docker-machine scp -r myFolder/ machineName:/tmp
docker-machine ssh machineName sudo cp -r /tmp/myFolder /path/to/actual/destination

MatrixManAtYrService avatar Jun 18 '16 18:06 MatrixManAtYrService

Is there a more elegant solution to this than the above? It works but seems counter to what you'd want to do.

n0wak avatar Jul 12 '18 14:07 n0wak

wow, this is hacky...

awhillas avatar Oct 16 '18 12:10 awhillas

The correct syntax for copying files to a machine is the following: docker-machine scp path user@machine:path

So for example, it would be: docker-machine scp ./src ubuntu@my-machine:~/dest

Don't forget the ~ to indicate that you are copying to your home folder. If you simply put /dest, it will not work because the user (in the above example ubuntu does not have permissions outside ~/.

Dvisacker avatar Nov 23 '18 12:11 Dvisacker

the default password to copy is tcuser

RafaelRNunes avatar Apr 29 '21 21:04 RafaelRNunes