When using a GNOME desktop on Ubuntu, if I use OpenSSH client to connect to another computer (running from the gnome-terminal), I get a single graphic popup asking for my private key's pass-phrase. After that I no longer need to enter my pass-phrase as it is cached by the SSH agent.

Under KDE it doesn't work like that - when I start ssh from konsole, I get a text prompt for my pass-phrase every single time, even though ssh-agent is running.

If I run ssh-add from the terminal then I can enter my pass-phrase on the terminal and it will be stored by ssh-agent and I won't get any more pass-phrase prompts, while if I run ssh-add the KRunner graphical command line ("Run" dialog) then I get a graphical prompt with the same behavior. The problem is I have to remember running ssh-add every time I log in to the desktop.

How can I get ssh to behave under KDE, the same as it does on GNOME - the first time the pass-phrase is needed, pop up a graphical dialog and store the pass-phrase in the agent.

I've installed ksshaskpass, but that didn't change anything.

up vote 5 down vote accepted

I don't know the internals so to explain why in GNOME it works and in KDE it doesn't, but I can suggest a solution.

Define a function like the following in your ~/.bashrc:

ssh() {
    if ! ssh-add -l &>/dev/null; then
        ssh-add </dev/null &>/dev/null
    command ssh "$@"

i.e., if the agent has no key stored already (! ssh-add -l), then call it with input from /dev/null: this is to convince ssh-add has no terminal, and force to ask the password with a GUI window.

You could set the SSH_ASKPASS environment variable to point to a different application to ask for the password.

  • Thanks - it looks like an interesting workaround and i'll give it a try just to see how it operates, but I rather have a more system-level solution. – Guss Nov 28 '11 at 11:57
  • I didn't get an answer of the type that I wanted, but as no other answer appears to be forthcoming and this workaround appears to work very nicely for my needs - I'll accept it. Thanks @enzotib – Guss Dec 16 '11 at 10:07

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.