venth / aws-adfs

Command line tool to ease aws cli authentication against ADFS (multi factor authentication with active directory)
MIT License
286 stars 99 forks source link

aws-adfs: command not found #401

Closed castillo-alex closed 10 months ago

castillo-alex commented 11 months ago

After running pip install --user -aws-adfs I receive the following error when running aws-adfs: bash-3.2$ aws-adfs bash: aws-adfs: command not found

pdecat commented 10 months ago

Remove the - before aws-adfs in pip install --user -aws-adfs: pip install --user aws-adfs.

Also, you may need to run hash -r after installation to tell bash to refresh its cache.

castillo-alex commented 10 months ago

Thanks for the suggestion @pdecat. I tried this but still get the same result

pdecat commented 10 months ago

Can you try clearing bash cache with hash -r?

castillo-alex commented 10 months ago

Yes, tried that and also terminated the terminal and opened a new one. No luck yet

pdecat commented 10 months ago

What does python -V output?

Also, what's the output of pip install --user aws-adfs?

Is $HOME/.local/bin/ in your PATH?

castillo-alex commented 10 months ago

What does python -V output?:

bash-3.2$ python --version
Python 3.8.5
bash-3.2$ 

Also, what's the output of pip install --user aws-adfs?

bash-3.2$ pip install --user aws-adfs
Requirement already satisfied: aws-adfs in ./.local/lib/python3.8/site-packages (2.8.1)
Requirement already satisfied: requests-kerberos<0.15,>=0.14; platform_system != "Windows" in ./.local/lib/python3.8/site-packages (from aws-adfs) (0.14.0)
Requirement already satisfied: boto3<2.0,>=1.24 in ./.local/lib/python3.8/site-packages (from aws-adfs) (1.28.24)
Requirement already satisfied: botocore<2.0,>=1.23 in ./.local/lib/python3.8/site-packages (from aws-adfs) (1.31.24)
Requirement already satisfied: fido2<2.0,>=1.0 in ./.local/lib/python3.8/site-packages (from aws-adfs) (1.1.2)
Requirement already satisfied: click<9.0,>=8.0 in ./.local/lib/python3.8/site-packages (from aws-adfs) (8.1.6)
Requirement already satisfied: lxml<5.0,>=4.9 in ./.local/lib/python3.8/site-packages (from aws-adfs) (4.9.3)
Requirement already satisfied: requests<3.0,>=2.27 in ./.local/lib/python3.8/site-packages (from aws-adfs) (2.31.0)
Requirement already satisfied: configparser==5.3.0 in ./.local/lib/python3.8/site-packages (from aws-adfs) (5.3.0)
Requirement already satisfied: cryptography>=1.3 in ./opt/anaconda3/lib/python3.8/site-packages (from requests-kerberos<0.15,>=0.14; platform_system != "Windows"->aws-adfs) (3.1.1)
Requirement already satisfied: pyspnego[kerberos] in ./.local/lib/python3.8/site-packages (from requests-kerberos<0.15,>=0.14; platform_system != "Windows"->aws-adfs) (0.9.1)
Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in ./.local/lib/python3.8/site-packages (from boto3<2.0,>=1.24->aws-adfs) (1.0.1)
Requirement already satisfied: s3transfer<0.7.0,>=0.6.0 in ./.local/lib/python3.8/site-packages (from boto3<2.0,>=1.24->aws-adfs) (0.6.1)
Requirement already satisfied: urllib3<1.27,>=1.25.4 in ./opt/anaconda3/lib/python3.8/site-packages (from botocore<2.0,>=1.23->aws-adfs) (1.25.11)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in ./opt/anaconda3/lib/python3.8/site-packages (from botocore<2.0,>=1.23->aws-adfs) (2.8.1)
Requirement already satisfied: idna<4,>=2.5 in ./opt/anaconda3/lib/python3.8/site-packages (from requests<3.0,>=2.27->aws-adfs) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in ./opt/anaconda3/lib/python3.8/site-packages (from requests<3.0,>=2.27->aws-adfs) (2020.6.20)
Requirement already satisfied: charset-normalizer<4,>=2 in ./.local/lib/python3.8/site-packages (from requests<3.0,>=2.27->aws-adfs) (3.2.0)
Requirement already satisfied: six>=1.4.1 in ./opt/anaconda3/lib/python3.8/site-packages (from cryptography>=1.3->requests-kerberos<0.15,>=0.14; platform_system != "Windows"->aws-adfs) (1.15.0)
Requirement already satisfied: cffi!=1.11.3,>=1.8 in ./opt/anaconda3/lib/python3.8/site-packages (from cryptography>=1.3->requests-kerberos<0.15,>=0.14; platform_system != "Windows"->aws-adfs) (1.14.3)
Requirement already satisfied: gssapi>=1.6.0; sys_platform != "win32" and extra == "kerberos" in ./.local/lib/python3.8/site-packages (from pyspnego[kerberos]->requests-kerberos<0.15,>=0.14; platform_system != "Windows"->aws-adfs) (1.8.2)
Requirement already satisfied: krb5>=0.3.0; sys_platform != "win32" and extra == "kerberos" in ./.local/lib/python3.8/site-packages (from pyspnego[kerberos]->requests-kerberos<0.15,>=0.14; platform_system != "Windows"->aws-adfs) (0.5.0)
Requirement already satisfied: pycparser in ./opt/anaconda3/lib/python3.8/site-packages (from cffi!=1.11.3,>=1.8->cryptography>=1.3->requests-kerberos<0.15,>=0.14; platform_system != "Windows"->aws-adfs) (2.20)
Requirement already satisfied: decorator in ./opt/anaconda3/lib/python3.8/site-packages (from gssapi>=1.6.0; sys_platform != "win32" and extra == "kerberos"->pyspnego[kerberos]->requests-kerberos<0.15,>=0.14; platform_system != "Windows"->aws-adfs) (4.4.2)
bash-3.2$ 

Is $HOME/.local/bin/ in your PATH?

bash-3.2$ echo $PATH
/Users/mini/.rvm/gems/ruby-2.6.3/bin:/Users/mini/.rvm/gems/ruby-2.6.3@global/bin:/Users/mini/.rvm/rubies/ruby-2.6.3/bin:/Users/mini/opt/anaconda3/bin:/Users/mini/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/mini/.rvm/bin:/Users/mini/.rvm/bin
bash-3.2$ 
pdecat commented 10 months ago

It's a matter of PATH then. Add $HOME/.local/bin/ to your PATH and you should be good.

See https://github.com/pypa/pip/issues/3813 for reference.

castillo-alex commented 10 months ago

Unfortunately still getting an error after adding $HOME/.local/bin/ to PATH

bash-3.2$ echo $PATH
/Users/mini/.rvm/gems/ruby-2.6.3/bin:/Users/mini/.rvm/gems/ruby-2.6.3@global/bin:/Users/mini/.rvm/rubies/ruby-2.6.3/bin:/Users/mini/opt/anaconda3/bin:/Users/mini/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/$HOME/.local/bin:/Users/mini/.rvm/bin:/Users/mini/.rvm/bin
bash-3.2$ aws-adfs
bash: aws-adfs: command not found
bash-3.2$ 

I do see the aws-adfs directory however...

bash-3.2$ cd $HOME/.local/bin
bash-3.2$ ls
__pycache__ aws-adfs    jp.py       normalizer  pyspnego-parse
pdecat commented 10 months ago

Not sure how you did it, I guess you probably escaped the dollar sign, but you shouldn't see $HOME when echoing $PATH, it should have been converted to your actual home directory path, /Users/mini in your case. Add /Users/mini/.local/bin/ as a work-around.

castillo-alex commented 10 months ago
bash-3.2$ aws-adfs
Usage: aws-adfs [OPTIONS] COMMAND [ARGS]...

Options:
  --version      Show current tool version
  -v, --verbose  Enables debug information on stdout. By default log level is
                 set on ERROR
  --help         Show this message and exit.

Commands:
  list   lists available profiles
  login  Authenticates an user with active directory credentials
  reset  removes stored profile

Success! Thanks for your help @pdecat!