pimalaya / himalaya

CLI to manage emails
https://pimalaya.org
MIT License
3.17k stars 95 forks source link

[Question] setup with pass and sync #350

Closed timsofteng closed 2 years ago

timsofteng commented 2 years ago

Hello. I want to try Himalaya but I don't know how to setup it properly. I want to put passes with gnu pass. How can I fill gpg password in gpg-agent and run Himalaya to watch my accounts and send notifications?

soywod commented 2 years ago

Did you check the wiki? You have full of resources that could help you build your config file. You even have an example with pass:

name = "Your Name"

[you-account-name]
default = true
email = "your@email.com"

smtp-host = "your@smtp.com"
smtp-port = 465
smtp-login = "your@email.com"
smtp-passwd-cmd = "pass show gmail"

imap-host = "your@imap.com"
imap-port = 993
imap-login = "your@email.com"
imap-passwd-cmd = "pass show gmail"

Feel free to open a discussion if you still cannot run Himalaya on your own.

timsofteng commented 2 years ago

@soywod looks like you don't understand. I've filled creds exactly as wiki and readme described. The problem is I have gpg password to show any pass. Himalaya doesn't invoke gpg-agent to fill the password.

> himalaya list
Error: cannot login to IMAP server

Caused by:
    No Response: Empty username or password.
soywod commented 2 years ago

@soywod looks like you don't understand.

Sorry, your initial question was not so clear.

The problem is I have gpg password to show any pass. Himalaya doesn't invoke gpg-agent to fill the password.

I understand better now. Are you sure your gpg-agent is running properly? Also, gpg-agent relies on a pinentry program, is it well set up? My ~/.gnupg/gpg-agent.conf is automatically generated by NixOS 1, but it looks like this:

enable-ssh-support
default-cache-ttl 86400
default-cache-ttl-ssh 86400
max-cache-ttl 604800
max-cache-ttl-ssh 604800
pinentry-program /nix/store/l0sqgkx71ap4b2fd6hwpjy54vxdqcgw4-pinentry-1.2.0-gtk2/bin/pinentry

I also use gpg and pass, and when I run himalaya it asks for my password in a GTK window.

Let me know if it helps you.

On 23 Mar 2022, at 12:59 (+0100), soywod/himalaya wrote:

@soywod looks like you don't understand. I've filled creds exactly as wiki and readme described. The problem is I have gpg password to show any pass. Himalaya doesn't invoke gpg-agent to fill the password.

> himalaya list
Error: cannot login to IMAP server

Caused by:
 No Response: Empty username or password.

-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/350#issuecomment-1076293510 You are receiving this because you were mentioned.

Message ID: @.***>

-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me

timsofteng commented 2 years ago

@soywod I didn't configured gpg-config, but aerc invoke gpg-agent before launching without problems.

Pinentry exists as well.

> which pinentry
/usr/bin/pinentry
soywod commented 2 years ago

@soywod I didn't configured gpg-config, but aerc invoke gpg-agent before launching without problems.

But aerc is a TUI, not a CLI like Himalaya, and it does not make sense as a CLI to spawn a gpg-agent. However it could be a good addition for the future Himalaya's TUI 1 and GUI 2.

Could you try to start gpg-agent manually (usually with a eval $(gpg-agent --daemon)) and see if Himalaya works?

On 23 Mar 2022, at 14:27 (+0100), soywod/himalaya wrote:

@soywod I didn't configured gpg-config, but aerc invoke gpg-agent before launching without problems.

-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/350#issuecomment-1076374802 You are receiving this because you were mentioned.

Message ID: @.***>

-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me

timsofteng commented 2 years ago

Here:

> eval $(gpg-agent --daemon)
gpg-agent: a gpg-agent is already running - not starting a new one
> himalaya list
Error: cannot login to IMAP server

Caused by:
    No Response: Empty username or password. 

I'm not sure I have installed gui gpg-agent. However what If I want to launch himalaya from tty?

timsofteng commented 2 years ago

@soywod

soywod commented 2 years ago

Sorry @timsofteng, I did not receive any notification for you reply.

It is really strange, I cannot understand what is going on. Which system do you run? Could you share your Himalaya's configuration?

On 27 Mar 2022, at 22:07 (+0200), soywod/himalaya wrote:

@soywod

-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/350#issuecomment-1080009369 You are receiving this because you were mentioned.

Message ID: @.***>

-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me

timsofteng commented 2 years ago

@soywod That's ok.

Sure. Here:

name = "Tim"
downloads-dir = "~/downloads"
signature = "Cordialement,\nTim"
default-page-size = 50

[mygmail]
default = true
email = "my@gmail.com"

imap-host = "imap.gmail.com"
imap-port = 993
imap-login = "my@gmail.com"
imap-passwd-cmd = "pass show gmail"

smtp-host = "smtp.gmail.com"
smtp-port = 465
smtp-login = "my@gmail.com"
smtp-passwd-cmd = "pass show gmail"
soywod commented 2 years ago

Thank you. Which operating system do you use? I see you use Gmail, do you use your real Gmail password with pass? If so, please check this wiki page 1.

On 28 Mar 2022, at 14:48 (+0200), soywod/himalaya wrote:

@soywod That's ok.

Sure. Here:

name = "Tim"
downloads-dir = "~/downloads"
signature = "Cordialement,\nTim"
default-page-size = 50

[mygmail]
default = true
email = ***@***.***"

imap-host = "imap.gmail.com"
imap-port = 993
imap-login = ***@***.***"
imap-passwd-cmd = "pass show gmail"

smtp-host = "smtp.gmail.com"
smtp-port = 465
smtp-login = ***@***.***"
smtp-passwd-cmd = "pass show gmail"

-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/350#issuecomment-1080607702 You are receiving this because you were mentioned.

Message ID: @.***>

-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me

timsofteng commented 2 years ago

@soywod Os: Alpine edge

I use app path. If I put it to the config directly Himalaya works.

I guess it is gpg-agent displaying issue

soywod commented 2 years ago

This 1 could help you somehow?

On 28 Mar 2022, at 17:50 (+0200), soywod/himalaya wrote:

@soywod Os: Alpine edge

I use app path. If I put it to the config directly Himalaya works.

I guess it is gpg-agent displaying issue

-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/350#issuecomment-1080820505 You are receiving this because you were mentioned.

Message ID: @.***>

-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me

timsofteng commented 2 years ago

@soywod no This is wrong solution:

pinentry-mode

    This option is used to change the operation mode of the pinentry. The following values are defined:

    ask

        This is the default mode which pops up a pinentry as needed.
    cancel

        Instead of popping up a pinentry, return the error code GPG_ERR_CANCELED.
    error

        Instead of popping up a pinentry, return the error code GPG_ERR_NO_PIN_ENTRY.
    loopback

        Use a loopback pinentry. This fakes a pinentry by using inquiries back to the caller to ask for a passphrase. This option may only be set if the agent has been configured for that. To disable this feature use [option --no-allow-loopback-pinentry](https://www.gnupg.org/(it)/documentation/manuals/gnupg/Agent-Options.html#option-_002d_002dno_002dallow_002dloopback_002dpinentry).
timsofteng commented 2 years ago

Pinentry work with pass or aerc. So the issue is probably with himalaya.

soywod commented 2 years ago

Himalaya runs commands using sh -c "<cmd>" sources, maybe this is an issue on Alpine OS. Could you try to run in you terminal sh -c "pass show gmail" and see if gpg-agent prompts for your password?

On 30 Mar 2022, at 10:24 (+0200), soywod/himalaya wrote:

Pinentry work with pass or aerc. So the issue is probably with himalaya.

-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/350#issuecomment-1082775770 You are receiving this because you were mentioned.

Message ID: @.***>

-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me

timsofteng commented 2 years ago

@soywod Yes, this command works in shell and gpg-agent tui is appearing.

soywod commented 2 years ago

I tried all kind of pinentry (TUI, GUI) and I cannot reproduce your issue. I still think it is related to your gpg-agent configuration. Can you try to runexport GPG_TTY="$(tty)" before running himalaya? If it does not work then I have no other clue, I cannot help anymore since I cannot reproduce :(

On 30 Mar 2022, at 12:21 (+0200), soywod/himalaya wrote:

@soywod Yes, this command works in shell and gpg-agent tui is appearing.

-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/350#issuecomment-1082902916 You are receiving this because you were mentioned.

Message ID: @.***>

-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me

timsofteng commented 2 years ago

@soywod export GPG_TTY="$(tty)"

Works after this command! Tui gpg dialog appears! So do you have idea whats wrong with my stuff?

timsofteng commented 2 years ago

please notice that mbsync -a work well without any tweaks.

soywod commented 2 years ago

Awesome! I searched a bit more about this command and in fact you should be the one to put in your shell's config file. From the gpg doc:

You should always add the following lines to your .bashrc or whatever initialization file is used for all shell invocations: GPG_TTY=$(tty) export GPG_TTY

From the [neomutt] repo also:

For the gpg-agent to be able to ask you the unlock passphrase, the environment variable GPG_TTY must be set to the current tty. Typically you would put the following inside your .profile or equivalent: export GPG_TTY=$(tty)

I guess we can close the issue?

On 30 Mar 2022, at 15:27 (+0200), soywod/himalaya wrote:

export GPG_TTY="$(tty)"

Works after this command! Tui gpg dialog appears! So do you have idea whats wrong with my stuff?

-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/350#issuecomment-1083139911 You are receiving this because you were mentioned.

Message ID: @.***>

-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me

timsofteng commented 2 years ago

@soywod This hack doen't work well. It works in in parent tty after login but when I start sway and open terminal in sway session it doesn't work. Even apps which works before doesn't work. So this is bad solution unfortunately.

soywod commented 2 years ago

Unfotunately this hack doen't work well.

Well, it is not a hack, it is the official procedure from GPG. This command is for gpg-agent to know where is located the file of the terminal connected to standard input.

but when I start sway and open terminal in sway session it doesn't work.

It means you did not put the command at the right place. If you run echo $GPG_TTY you get an empty string I guess? It should be in you .bashrc (if you use bash) or even better in your .profile so it is loaded once for all your session.

On 30 Mar 2022, at 17:28 (+0200), soywod/himalaya wrote:

Unfotunately this hack doen't work well. It works in in parent tty after login but when I start sway and open terminal in sway session it doesn't work. Even apps which works before doesn't work. So this is bad solution unfortunately.

-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/350#issuecomment-1083288733 You are receiving this because you were mentioned.

Message ID: @.***>

-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me

timsofteng commented 2 years ago

@soywod I'll try to explain why it doesn't work for me. So imagine I've added export GPG_TTY=$(tty) into .profile Then I boot into system and feel credentialsin tty. I'm in tty in my shell. Variable has been set to CURRENT TTY. Than I type sway to boot my graphic desktop. And if I will invoke himalaya list the gpg-agent will apper in my TTY, not in terminal emulator inside of sway. Do you understand what I mean?

soywod commented 2 years ago

I understand, but this is a problem related to your setup, not himalaya. I cannot do that much there :/

On 04 Apr 2022, at 17:09 (+0200), soywod/himalaya wrote:

@soywod I'll try to explain why it doesn't work for me. So imagine I've added export GPG_TTY=$(tty) into .profile Then I boot into system and feel credentialsin tty. I'm in tty in my shell. Variable has been set to CURRENT TTY. Than I type sway to boot my graphic desktop. And if I will invoke himalaya list the gpg-agent will apper in my TTY, not in terminal emulator inside of sway. Do you understand what I mean?

-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/350#issuecomment-1087680917 You are receiving this because you were mentioned.

Message ID: @.***>

-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me

soywod commented 2 years ago

gpg-agent: a gpg-agent is already running - not starting a new one

So it's not a gpg-agent issue. Could you share your Himalaya's config file? On which system do you run?

On 23 Mar 2022, at 15:02 (+0100), soywod/himalaya wrote:

Here:

> eval $(gpg-agent --daemon)
gpg-agent: a gpg-agent is already running - not starting a new one
> himalaya list
Error: cannot login to IMAP server

Caused by:
 No Response: Empty username or password. 

-- Reply to this email directly or view it on GitHub: https://github.com/soywod/himalaya/issues/350#issuecomment-1076411683 You are receiving this because you were mentioned.

Message ID: @.***>

-- Cordialement Clément DOUIN Développeur Web Full-Stack https://soywod.me