Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

[Bug] Remember ssh key passphrase #875

Closed
Schueni1 opened this issue Jun 22, 2020 · 32 comments · Fixed by #880 or #884
Closed

[Bug] Remember ssh key passphrase #875

Schueni1 opened this issue Jun 22, 2020 · 32 comments · Fixed by #880 or #884
Assignees
Milestone

Comments

@Schueni1
Copy link

App Version: 1.9

Since version 1.9 the "Remember passphrase" feature for the ssh key is not working anymore.

After pulling down two or three times to synchronise the remote git repo I get asked for the ssh passphrase.

@msfjarvis
Copy link
Member

Please do not remove the issue template when reporting bugs, it makes things harder than they need to be :(

@msfjarvis msfjarvis self-assigned this Jun 23, 2020
@msfjarvis msfjarvis added this to the 1.10.0 milestone Jun 23, 2020
@msfjarvis
Copy link
Member

I just automated 50 sync operations and was never prompted for my passphrase, please update the issue with reliable reproduction steps as mentioned in the bug report template.

@moppman
Copy link
Contributor

moppman commented Jun 23, 2020

Not OP, but probably related:
My ssh key has no passphrase. Since 1.9.0, I am prompted to set a passphrase or leave the textfield empty on each sync.
If I leave it empty (i.e. don't set a passphrase), syncing works. However, the "remember passphrase" flag doesn't seem to be honored on an empty passphrase, because I'm prompted again on each sync.

@msfjarvis
Copy link
Member

Not OP, but probably related:
My ssh key has no passphrase. Since 1.9.0, I am prompted to set a passphrase or leave the textfield empty on each sync.
If I leave it empty (i.e. don't set a passphrase), syncing works. However, the "remember passphrase" flag doesn't seem to be honored on an empty passphrase, because I'm prompted again on each sync.

That's very helpful, thanks!

@fmeum
Copy link
Member

fmeum commented Jun 23, 2020

@moppman Do you know how you generated your key? I cannot reproduce this with a key with no passphrase generated directly within Password Store, but it might very well happen with imported key files in other formats.

@moppman
Copy link
Contributor

moppman commented Jun 23, 2020

@moppman Do you know how you generated your key? I cannot reproduce this with a key with no passphrase generated directly within Password Store, but it might very well happen with imported key files in other formats.

@FabianHenneke I generated my key via ssh-keygen from the openssh-client Debian package and then imported it into Password Store.

@fmeum
Copy link
Member

fmeum commented Jun 23, 2020

@moppman Do you know how you generated your key? I cannot reproduce this with a key with no passphrase generated directly within Password Store, but it might very well happen with imported key files in other formats.

@FabianHenneke I generated my key via ssh-keygen from the openssh-client Debian package and then imported it into Password Store.

Okay, I should be able to reproduce this then. Which key type are you using and when did you generate the key approximately (this year, five years ago,...)?

@msfjarvis msfjarvis assigned fmeum and unassigned msfjarvis Jun 23, 2020
@moppman
Copy link
Contributor

moppman commented Jun 23, 2020

The key is a 4096 bit RSA key from Feb. 2018.

@Schueni1
Copy link
Author

Same for me. 4096 bit RSA key generated about 3 years ago.

@fmeum
Copy link
Member

fmeum commented Jun 23, 2020

Could you test whether #880 fixes this for you?

@msfjarvis and I did not catch this during testing since we were using key files generated either in the app or with a current version of OpenSSH. OpenSSH changed the default key file format in late 2018 and the new key files do no longer use an empty string as passphrase if they are not encrypted, but indicate this directly.

@fmeum
Copy link
Member

fmeum commented Jun 24, 2020

@Schueni1 @moppman Starting with 1.9.0, Password Store also supports ssh-ed25519 keys. You might want to give it a try and replace your old keys, the new ones will certainly sign much faster.

@Schueni1
Copy link
Author

I just generated a new ssh key with the following command:

ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "me@example.xyz"

and imported it on the app. This solved the problem for me!

Though I think it isn't perfect that version 1.9 breaks the Remember-Feature for 4096bit RSA SSH keys.

@fmeum
Copy link
Member

fmeum commented Jun 24, 2020

It does break it only for RSA SSH key files generated before 2019.

@msfjarvis If the fix solves the problem, should we publish it as a point release?

@msfjarvis
Copy link
Member

It does break it only for RSA SSH key files generated before 2019.

@msfjarvis If the fix solves the problem, should we publish it as a point release?

Yeah I think we should. Please create a 1.9.1 milestone and move this issue and the PR to it.

@msfjarvis
Copy link
Member

I tried to test this with RSA2048 and RSA4096 keys from OpenSSH 6.6.1p1, but I've still not received a passphrase prompt yet. Is there a specific set of flags I must pass to ssh-keygen? I've tried these so far:

ssh-keygen -t rsa -b 2048
ssh-keygen -t rsa -b 4096
ssh-keygen -o -a 100 -t rsa -b 4096

@msfjarvis msfjarvis modified the milestones: 1.10.0, 1.9.1 Jun 24, 2020
@fmeum
Copy link
Member

fmeum commented Jun 24, 2020

I tried to test this with RSA2048 and RSA4096 keys from OpenSSH 6.6.1p1, but I've still not received a passphrase prompt yet. Is there a specific set of flags I must pass to ssh-keygen? I've tried these so far:

ssh-keygen -t rsa -b 2048
ssh-keygen -t rsa -b 4096
ssh-keygen -o -a 100 -t rsa -b 4096

I managed to reproduce the issue by passing in -m PEM using a modern version of OpenSSH.

@Schueni1
Copy link
Author

Schueni1 commented Jun 24, 2020

Is this going to fix the empty password problem only or will it also work with old ssh keys with a password?

I don't know exactly when I generated my old ssh key and the openssh version I used 😕

@msfjarvis
Copy link
Member

Is this going to fix the empty password problem only or will it also work with old ssh keys with a password?

I don't know exactly when I generated my old ssh key and the openssh version I used

I'm not sure either tbh. Care to find out? Snapshot build

@Schueni1
Copy link
Author

Schueni1 commented Jun 24, 2020

Nope. It does not. I just reimported the old ssh key on the new snapshot version and I'm still prompted for a password.

@msfjarvis
Copy link
Member

That's a bummer. If you can provide some details (like key type and size) then hopefully @FabianHenneke would be able to dig up something.

@fmeum
Copy link
Member

fmeum commented Jun 24, 2020

I would be particularly interested in reproduction steps. Does the issue really only show up after the third refresh gesture?

@Schueni1
Copy link
Author

Schueni1 commented Jun 24, 2020

Hmmm. As I said it is 4096Bit rsa key generated about 2 or 3 years ago with ssh-keygen. I don't know which version of openssh it was.

I just generated a new 4096 bit rsa key and this is how it looks:


-----BEGIN OPENSSH PRIVATE KEY-----
RandomData
-----END RSA PRIVATE KEY-----

This is how my old rsa key looks like:

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,4CF**************************C4C

RandomData
-----END RSA PRIVATE KEY-----

The fourth line in the old ssh-key private file is an empty line. Just before the random data starts.

@Schueni1
Copy link
Author

Schueni1 commented Jun 24, 2020

It always shows up after the second refresh gesture.

Reproduction steps:

  1. Import the old rsa ssh key on either app version 1.9 or 1.10-snapshot.
  2. Pull down to refresh (Not prompted for a password)
  3. Pull down again -> Prompted for a password

How reproducable is this?
100%

Does clearing cache and data make a difference?
No

With the new generated rsa key I'm not prompted for a password.
Removing any of the three lines after -----BEGIN RSA PRIVATE KEY----- from the old key breaks it and I always get a wrong password message when I try to use it.

@Schueni1
Copy link
Author

Schueni1 commented Jun 25, 2020

I just managed to reproduce this error with a new key.
I used this version of openssh:
OpenSSH_8.3p1, OpenSSL 1.1.1g 21 Apr 2020
and generated the key with the following command:
ssh-keygen -o -b 4096 -f ~/.ssh/test -C "test@test.xyz" -m PEM and entered a password when I was prompted for it.
Then I imported the key on the app and after the second refresh I am prompted for a password.

@fmeum
Copy link
Member

fmeum commented Jun 25, 2020

I just managed to reproduce this error with a new key.
I used this version of openssh:
OpenSSH_8.3p1, OpenSSL 1.1.1g 21 Apr 2020
and generated the key with the following command:
ssh-keygen -o -b 4096 -f ~/.ssh/test -C "test@test.xyz" -m PEM and entered a password when I was prompted for it.
Then I imported the key on the app and after the second refresh I am prompted for a password.

I can reproduce the issue with these steps and will investigate. Thanks!

@msfjarvis In passing: The "wrong passphrase" indicator overlaps the new "view password" toggle button. Maybe there is some other Material style visualization for errors?

@fmeum
Copy link
Member

fmeum commented Jun 25, 2020

@Schueni1 @msfjarvis The root cause is this line in the decoder for the old-style private key file format. It clears the buffer that holds the passphrase bytes and we are currently passing this buffer by reference. The decoder for new-style private key files doesn't clear the buffer.

To fix this, I will pass a copy of the buffer. I have also submitted hierynomus/sshj#609 to ensure that sshj wipes as much as possible.

@fmeum
Copy link
Member

fmeum commented Jun 25, 2020

Something else is broken too, though. Will have to take a deeper look.

@msfjarvis
Copy link
Member

@msfjarvis In passing: The "wrong passphrase" indicator overlaps the new "view password" toggle button. Maybe there is some other Material style visualization for errors?

I'll get that sorted.

fmeum pushed a commit that referenced this issue Jun 26, 2020
* Use remembered credential even if it is empty

Should fix #875.

* .isNull() --> == null

* Update relnotes

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>

* Reword relnotes

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>

* 2019 it is

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>

Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
@msfjarvis
Copy link
Member

msfjarvis commented Jun 27, 2020

@msfjarvis In passing: The "wrong passphrase" indicator overlaps the new "view password" toggle button. Maybe there is some other Material style visualization for errors?

I imagine this is a regression (material-components/material-components-android#1444), I'll walk back a couple versions and see if I can find where this works. Scratch that, Kotlin was the problem. Fixed it by doing this.

@fmeum
Copy link
Member

fmeum commented Jun 28, 2020

@Schueni1 Could you verify whether the issue is fixed in the current snapshot build? We merged the PR that should fix it.

@Schueni1
Copy link
Author

Yes it works! I'm not prompted for a passphrase any more.

@msfjarvis
Copy link
Member

Great, I'll prep 1.9.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants