Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access SFTP with SSH Key having a password #349

Open
qmachard opened this issue Apr 12, 2017 · 6 comments
Open

Can't access SFTP with SSH Key having a password #349

qmachard opened this issue Apr 12, 2017 · 6 comments
Labels
confirmed enhancement New feature or improvement

Comments

@qmachard
Copy link

Hi,

First, good job for this useful and amazing tool !!

So, I can't connect me to a server in SFTP with my private key having a password. It's ok when I remove the password from my ssh key but I've would like to have one 馃槈

* SSH MD5 fingerprint: a926164b3ca7b2a093cd93050e3a7ff2
* SSH authentication methods available: publickey,password,keyboard-interactive
* Using SSH private key file '/Users/me/.ssh/id_rsa'
* SSH public key authentication failed: Unable to extract public key from private key file: Wrong passphrase or invalid/unrecognized private key file format
* No identity would match
* Authentication failure
* Closing connection 0

I'm on macOS Sierra 10.12.4 (16E195)

Thank you,
Bye.

@mkllnk mkllnk added confirmed enhancement New feature or improvement labels Apr 17, 2017
@mkllnk
Copy link
Member

mkllnk commented Apr 17, 2017

Yes, that would be great. Thank you for reporting.

@martisj
Copy link

martisj commented Aug 24, 2017

@qmachard can you please share your .git/config? I can't get sftp working with a key with/without password.

@LukasFritzeDev
Copy link
Collaborator

I just found this in the curl manual:

Get a file from an SSH server using SCP using a private key (password-protected) to authenticate:

    curl -u username: --key ~/.ssh/id_rsa --pass private_key_password \ 
         scp://example.com/~/file.txt

It might help here.

@LukasFritzeDev
Copy link
Collaborator

So what would be the best logic to implement this?

  1. Introduce a new option/config --key-pass which must be set explicitly.
  2. Set this from the already existing --passwd (or any other method of setting a password) only if a password and a private key are set at the same time. But this has potential to lead to some unexpected behaviour in some use cases.

@mkllnk
Copy link
Member

mkllnk commented Jul 27, 2019

At first, I preferred option 1 to reduce the potential for conflict. But then I thought that some people may prefer to enter their password instead of storing it. If we use the current password, we can reuse all the logic, keychain usage and so on. I would go for that as it's much simpler.

@rraallvv
Copy link

rraallvv commented Jan 14, 2020

Is this related t this issue?

* SSH authentication methods available: publickey
* Using SSH public key file '/Users/user/.ssh/id_rsa.pub'
* Using SSH private key file '/Users/user/.ssh/id_rsa'
* SSH public key authentication failed: Callback returned error
* No identity would match
* Authentication failure
* Closing connection 0

Please notice the error is different, Callback returned error, and that id_rsa.pub is already in the ~/.ssh directory

Edit:

There are cases (debian-based distros) when your libssh2 is built with libgcrypt. In those, use PEM-encoded private key file in .git/conf:

$ openssl rsa -in ~/.ssh/id_rsa -outform pem > ~/.ssh/id_rsa.pem

Source: https://stackoverflow.com/a/17884284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

5 participants