MadPhysicist MadPhysicist - 18 days ago 15
Linux Question

AWS EC2 Permissions Denied /usr/local/bin cURL

I am trying to follow this documentation and install docker machine on my EC2 instance. However, the curl command:

curl -L https://github.com/docker/machine/releases/download/v0.8.2/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine


quits with the error:


-bash: /usr/local/bin/docker-machine: Permission denied


I tried to curl into the home directory, hoping that it would change the permissions on the directory and then copy it to destination, but it didn't work.

How can I by-pass this? Clearly, the ec2-user is lacking the root privileges on some directories.

Answer

-v When given the -v (validate) option, sudo will update the user's cached credentials, authenticating the user's password if necessary. For the sudoers plugin, this extends the sudo timeout for another 5 minutes (or whatever the timeout is set to by the security policy) but does not run a command. Not all security policies support cached credentials.

ec2-user is in sudoers list by default.

[ec2-user ~]$ sudo -v
[ec2-user ~]$

Try this:

sudo bash -c "curl -L https://github.com/docker/machine/releases/download/v0.8.2/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine"

If you want to make the saved file an executable for all:

sudo chmod a+x /usr/local/bin/docker-machine