Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have everything set up so that after I log in and add proper identity to ssh-agent using ssh-add from a gnome-terminal window, I do not have to enter the passphrase again when I invoke ssh myserver.

Now I wanted to make it even easier and create a panel launcher that would run

gnome-terminal --command "ssh myserver"

but while this does invoke what I want, it ignores ssh-agent, i.e. it asks for pass-phrase. And it does so every time, even if I supply the PP, the next time it asks again.

What am I doing wrong? Can anybody explain why this does not work?

Further notes:

  • Running gnome-terminal --command "ssh myserver from already open terminal works OK

  • Changing ssh myserver part to bash -c "ssh myserver" with proper quoting did not help.

  • Also using ssh myserver right in the launcher did not help: the pass-phrase prompt was displayed as a simple GUI window (unless I checked "Run in terminal" option, in which case the behavior was same as described above)

  • It's Ubuntu 12.04

  • adding -vvv to both ssh command, here is where the failing (and asking for PP) ssh starts to differ from the successful ssh:

    debug1: Server accepts key: pkalg ssh-rsa blen 279
    debug2: input_userauth_pk_ok: fp 5e:ad:5e:1f:7f:...
    debug1: key_parse_private_pem: PEM_read_PrivateKey failed
    debug1: read PEM private key done: type <unknown>
    Enter passphrase for key '/home/lennycz/.ssh/id_rsa': 

    while the successful ssh says

    debug1: Server accepts key: pkalg ssh-rsa blen 279
    debug2: input_userauth_pk_ok: fp 5e:ad:5e:1f:7f:...
    debug1: Authentication succeeded (publickey).

    (and then lot of things apparently unrelated...)

    I haven't found any helpful debug messages around nor anything in system/auth logs.

share|improve this question
I assume you are aware that it will always ask for a passphrase the first time it's run, right? So, what version of Ubuntu are you using? I had a similar (or maybe same) problem with 11.10, but with 12.03 it is working correctly, using the same command as you. I'm using Gnome Classic/Fallback/whatever it's called, and created a simple panel app launcher. EDIT: sorry, I decided to look at your link, and I'm not doing anything at all like that. What is the purpose of that code over the standard setup? –  Marty Fried Dec 10 '12 at 22:47
FWIW, the method I use is to run ssh-keygen -t rsa for the client machine, then to copy the key to the remote system, I run ssh-copy-id <username>@<hostname>, assuming RSA and standard port 22. If not standard, there's a slight variation. I've used the ssh-agent method for cygwin in the past, but never needed it for Ubuntu for a long time. –  Marty Fried Dec 10 '12 at 22:55
@MartyFried Thanks for interest. I put some answers right in the Q. For the rest: A) I expect it to ask for PP only after I invoke ssh-add, then all subsequent ssh processes load it from ssh-agent. B) I'm not sure what you mean by "standard" way. What you describe in your 2nd comment is the auth part, which I've already done correctly (hence the ssh myserver works from previously opened terminal window). My problem is about ssh-agent, specifically that ssh, when invoked via launcher does not use it while ssh invoked from terminal window does. –  Alois Mahdal Dec 10 '12 at 23:39
Perhaps I'm mistaken, or simply forgot the details, but I thought that with ssh agent, you only needed to enter the PP once per session, and it then saved you from entering it every time you needed to do things like scp, etc. This is what I get automatically with Ubuntu, without any extra work. I don't remember, but perhaps at one time I decided that this was good enough, so I never needed more. If you want to never enter a PP even once, then I'm sorry I can't help. –  Marty Fried Dec 11 '12 at 0:51
@MartyFried I was expecting it to work like on my GUI-less Debian/Squeeze server: you run ssh-add, enter the PP and then use all ssh's and scp's and git pull/pushes without need to enter PP again. (Basically what you say except that on my box I explicitly need to call ssh-add.) –  Alois Mahdal Dec 11 '12 at 1:19
add comment

2 Answers

I assume you followed the linked article and modified your ~/.bashrc. However ~/.bashrc might never be sourced when you're running a command from a panel launcher.

An easy way to debug is adding date > /tmp/bashrc_sourced to then end of your ~/.bashrc and check if the current time is printed to the file when you invoke the panel launcher.

Related note: You might want to look at keychain, which is specifically designed to manage ssh-agent for you.

share|improve this answer
add comment

I'd suggest verifying that SSH_AUTH_SOCK is passed correctly.

I have this as part of my login script in KDE:

export SSH_AUTH_SOCK="${HOME}/.ssh-agent.sock"
rm -f ${SSH_AUTH_SOCK}
ssh-agent -a ${SSH_AUTH_SOCK}

and this in my .bashrc:

export SSH_AUTH_SOCK="${HOME}/.ssh-agent.sock"
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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