MadPhysicist MadPhysicist - 8 months ago 74
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`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 Source

-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`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