geluk / pass-winmenu

An easy-to-use password manager for Windows, compatible with pass.
MIT License
385 stars 25 forks source link

Note on creating a password store (Windows -> Linux) #22

Closed rvernica closed 6 years ago

rvernica commented 6 years ago

This is not necessarily a bug, but it might be worth having it somewhere.

The instructions for initializing a password store in Windows contain:

powershell> echo "myemail@example.com" | Out-File -Encoding utf8 $HOME\.password-store\.gpg-id

This creates a .gpg-id without a new-line at the end of the file.

This works fine in Windows, but once the password repository is cloned on Linux, pass is not happy about the missing new-line. The passwords can be decrypted fine, but when adding a new password you get:

> pass add Foo
Enter password for Foo:
Retype password for Foo:
gpg: no valid addressees
gpg: [stdin]: encryption failed: No user ID
Password encryption aborted.

You can debug this by using bash -x pass add Foo and you will see that the GPG command executed is:

gpg2 -e -o /home/user/.password-store/Foo.gpg --verbose --yes --compress-algo=none --no-encrypt-to --batch --use-agent

This is wrong as it is missing the -r myemail@example.com argument. The correct line is:

gpg2 -e -r myemail@example.com -o /home/user/.password-store/Foo.gpg --quiet --yes --compress-algo=none --no-encrypt-to --batch --use-agent

So, it seems that the pass script on Linux is not picking up the email address from the non new-line terminated .gpg-id file. Once you add a new-line at the end of .gpg-id everyone is happy.

geluk commented 6 years ago

That's odd, it seems to add the newline on my machine. Perhaps it depends on the PowerShell version? Mind showing the contents of your $PSVersionTable?

rvernica commented 6 years ago

I think you are right. Not sure how I ended up without a new-line. Never mind.