3

I've installed the awscli V2 as per the official AWS instructions here:

$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
$ unzip awscliv2.zip
$ sudo ./aws/install

The installation seems to work OK, except that I cannot use the aws command without sudo.

$ sudo aws --version
$ aws-cli/2.0.50 Python/3.7.3 Linux/5.4.0-47-generic exe/x86_64.ubuntu.20

Without sudo...

$ aws --version

Command 'aws' not found, but can be installed with:

sudo snap install aws-cli  # version 1.15.58, or
sudo apt  install awscli   # version 1.18.69-1ubuntu0.20.04.1

See 'snap info aws-cli' for additional versions.

Further details:

$ which aws # displays nothing
$ sudo which aws
/usr/local/bin/aws
$ /usr/local/bin/aws
bash: /usr/local/bin/aws: Permission denied

If I start to look at where the links are going they get very convoluted:

$ sudo ls -l /usr/local/bin/aws
lrwxrwxrwx 1 root root 37 Sep 21 16:43 /usr/local/bin/aws -> /usr/local/aws-cli/v2/current/bin/aws

$ sudo ls -l /usr/local/aws-cli/v2/current/bin/aws
lrwxrwxrwx 1 root root 11 Sep 21 16:43 /usr/local/aws-cli/v2/current/bin/aws -> ../dist/aws

$ sudo ls -l /usr/local/aws-cli/v2/2.0.50/dist
total 48400
-rwxr-x--- 1 root root   214121 Sep 21 16:43 array.cpython-37m-x86_64-linux-gnu.so
-rwxr-x--- 1 root root   237647 Sep 21 16:43 _asyncio.cpython-37m-x86_64-linux-gnu.so
-rwxr-x--- 1 root root  4136160 Sep 21 16:43 aws
drwxr-x--- 6 root root     4096 Sep 21 16:43 awscli
-rwxr-x--- 1 root root  4151368 Sep 21 16:43 aws_completer
.
.
.

In the final directory it appears that the execute bit has been dropped and this might be the problem, but this seems so fundamental an issue yet I can't find any other reports of this problem.

Can anyone tell me what is going on? Thank.

Adding o+x to the aws file in the last directory doesn't fix the problem. If I try installing via apt that seems to work OK, but I get the V1 API which I don't want.

P Burke
  • 183
  • 3
  • 12
  • It is truly mind boggling that Amazon would make such a large mistake in packaging their software. Learning permissions is one of the first things Linux admins and developers need to do. – Michael Hampton Sep 23 '20 at 17:07
  • Why not just do `sudo apt install awscli` ? failing that `pip install awscli` – Timothy c Sep 23 '20 at 20:02
  • 1
    @Timothyc using apt gives the V1 CLI, as that is the repo version. I could use pip, but I always prefer following the vendor's documented instructions where possible. – P Burke Sep 24 '20 at 11:04

2 Answers2

7

What worked for me was giving permission recursively to aws-cli folder

sudo chmod -R 755 /usr/local/aws-cli
semogmr
  • 86
  • 1
2

A better solution would be:

chmod -R o=g /usr/local/aws-cli

This will keep all of the file/directory permission restrictive for root, but allow all on the system to use the group permissions.

More information here Copy a file's owner permissions to group permissions

Davin
  • 21
  • 1