wallix / awless

A Mighty CLI for AWS
http://awless.io/
Apache License 2.0
4.97k stars 263 forks source link

SSH not working on mac #264

Closed tjwaterman99 closed 3 years ago

tjwaterman99 commented 5 years ago

I am trying to connect to my instance using awless.

awless list instances
|        ID ▲         |    ZONE    |  NAME   |  STATE  |  TYPE   |  PUBLIC IP   |  PRIVATE IP  | UPTIME  |     KEYPAIR     |
|---------------------|------------|---------|---------|---------|--------------|--------------|---------|-----------------|
| i-0238307e3e6765d92 | us-west-1c | tjw-dev | running | t2.nano | 54.67.75.182 | 172.31.0.127 | 22 mins | lastpass_id_rsa |

I'm able to connect using this command:

ssh ubuntu@54.67.75.182 -i ~/.ssh/lastpass_id_rsa

However awless ssh does not work.

awless ssh tjw-dev
This SSH key is encrypted. Please enter passphrase for key '/Users/tomwaterman/.ssh/lastpass_id_rsa':
[error]   unable to authenticate to 54.67.75.182:22 for users ["ec2-user" "ubuntu" "centos" "core" "bitnami" "admin" "root"]. Last error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

Specifying the username and key specifically with awless also does not work.

awless ssh -i ~/.ssh/lastpass_id_rsa ubuntu@54.67.75.182
This SSH key is encrypted. Please enter passphrase for key '/Users/tomwaterman/.ssh/lastpass_id_rsa':
[error]   unable to authenticate to 54.67.75.182:22 for users ["ubuntu"]. Last error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

Is there a way to discover what command awless ssh is using, to help debug what might be going on?

simcap commented 5 years ago

awless ssh tjw-dev --print-cli

simcap commented 5 years ago

awless ssh -h

tjwaterman99 commented 5 years ago

Thanks for helping @simcap. Unfortunately, it looks like the error is raised before the print-cli flag does any logging:

awless ssh tjw-dev --print-cli --verbose
[verbose] awless v0.1.11 - loading AWS session with profile 'default' and region 'us-west-1'
This SSH key is encrypted. Please enter passphrase for key '/Users/tomwaterman/.ssh/lastpass_id_rsa':
[error]   unable to authenticate to 54.67.75.182:22 for users ["ec2-user" "ubuntu" "centos" "core" "bitnami" "admin" "root"]. Last error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
danielelisi commented 4 years ago

Your private key needs to be decrypted before awless ssh can use it.

$ ssh-add ~/.ssh/<your_key>

This will ask to decrypt your key and will add it to your SSH agent session until next reboot/logout.

At this point awless ssh should work correctly

tjwaterman99 commented 3 years ago

@danielelisi Just rediscovered this issue, and your solution fixes it.

Thanks for helping!