darcs patch: add SshAgent module, to start ssh-agent when needed.

Hi all,
I'm sending this rather than pushing, since we're close to a release. It's
a new module to automatically start an ssh-agent, if one isn't running. I
expect to find it useful. The reason for this is that the ordinary
mechanism for starting a single ssh-agent for an X session doesn't seem to
be working for me. And starting xmonad with `ssh-agent xmonad` does no
good, because the ssh-agent exits as soon as I restart xmonad.
David
Sat Mar 29 11:49:11 CDT 2008 David Roundy

On 2008-03-29 12:55:15 David Roundy wrote:
I'm sending this rather than pushing, since we're close to a release. It's a new module to automatically start an ssh-agent, if one isn't running. I expect to find it useful. The reason for this is that the ordinary mechanism for starting a single ssh-agent for an X session doesn't seem to be working for me. And starting xmonad with `ssh-agent xmonad` does no good, because the ssh-agent exits as soon as I restart xmonad.
My .xsession has eval `ssh-agent` before it starts xmonad, and it seems to work fine. Does this not work for you? /J

On Mar 30, 2008, at 9:35 , Jamie Webb wrote:
On 2008-03-29 12:55:15 David Roundy wrote:
I'm sending this rather than pushing, since we're close to a release. It's a new module to automatically start an ssh-agent, if one isn't running. I expect to find it useful. The reason for this is that the ordinary mechanism for starting a single ssh-agent for an X session doesn't seem to be working for me. And starting xmonad with `ssh-agent xmonad` does no good, because the ssh-agent exits as soon as I restart xmonad.
My .xsession has
eval `ssh-agent`
before it starts xmonad, and it seems to work fine. Does this not work for you?
One caveat: .xsession is almost always a {,ba}sh script but the user's $SHELL might be {,t}csh, leading ssh-agent to do the wrong thing. Safest is "eval `ssh-agent -s`" to force it to use the sh/ bash commands. We tossed this around a bit on #xmonad last night and the above was the preferred solution. A variant that may solve other odd problems regarding placement and relay of ssh agent information to all subprocesses is: mv .xsession .xsession-real echo '#! /bin/sh' >.xsession echo 'exec ssh-agent $HOME/.xsession-real' >>.xsession chmod +x .xsession -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Sun, Mar 30, 2008 at 02:35:00PM +0100, Jamie Webb wrote:
On 2008-03-29 12:55:15 David Roundy wrote:
I'm sending this rather than pushing, since we're close to a release. It's a new module to automatically start an ssh-agent, if one isn't running. I expect to find it useful. The reason for this is that the ordinary mechanism for starting a single ssh-agent for an X session doesn't seem to be working for me. And starting xmonad with `ssh-agent xmonad` does no good, because the ssh-agent exits as soon as I restart xmonad.
My .xsession has
eval `ssh-agent`
before it starts xmonad, and it seems to work fine. Does this not work for you?
I don't know, it might. But I'm not going to restart X to find out. And I normally don't use a .xsession, since I use kdm to start xmonad. Except that right now I'm using a vnc most of the time, and that has its own file similar to .xsession. -- David Roundy Department of Physics Oregon State University

Hi, Am Samstag, den 29.03.2008, 12:55 -0400 schrieb David Roundy:
I'm sending this rather than pushing, since we're close to a release. It's a new module to automatically start an ssh-agent, if one isn't running. I expect to find it useful. The reason for this is that the ordinary mechanism for starting a single ssh-agent for an X session doesn't seem to be working for me. And starting xmonad with `ssh-agent xmonad` does no good, because the ssh-agent exits as soon as I restart xmonad.
David
Sat Mar 29 11:49:11 CDT 2008 David Roundy
* add SshAgent module, to start ssh-agent when needed.
I wonder if this can not be solved outside xmonad – just seems to be out of scope for a window manager. If Jamie’s tipp works out for you, I think that should not be part of xmonad. (But then, if you think it’d be really useful, go ahead.) Greetings, Joachim -- Joachim Breitner e-Mail: mail@joachim-breitner.de Homepage: http://www.joachim-breitner.de ICQ#: 74513189 Jabber-ID: nomeata@joachim-breitner.de

On Sun, Mar 30, 2008 at 09:48:47PM +0200, Joachim Breitner wrote:
Am Samstag, den 29.03.2008, 12:55 -0400 schrieb David Roundy:
I'm sending this rather than pushing, since we're close to a release. It's a new module to automatically start an ssh-agent, if one isn't running. I expect to find it useful. The reason for this is that the ordinary mechanism for starting a single ssh-agent for an X session doesn't seem to be working for me. And starting xmonad with `ssh-agent xmonad` does no good, because the ssh-agent exits as soon as I restart xmonad.
David
Sat Mar 29 11:49:11 CDT 2008 David Roundy
* add SshAgent module, to start ssh-agent when needed. I wonder if this can not be solved outside xmonad – just seems to be out of scope for a window manager. If Jamie's tip works out for you, I think that should not be part of xmonad. (But then, if you think it'd be really useful, go ahead.)
Perhaps what would be better would be a prompt module to modify xmonad's environment at runtime. Jamie's approach isn't truly general: if anything happens to that ssh-agent, then you're up the creek without a paddle. The only approach is to do something like kill and restart xmonad from the command line (or just restart X) in order to change the SSH_AGENT_PID environment variable and the other one. That's pretty ugly, and results in losing all xmonad's state in either case. -- David Roundy Department of Physics Oregon State University

On Mon, Mar 31, 2008 at 07:35:19AM -0700, David Roundy wrote:
I wonder if this can not be solved outside xmonad ??? just seems to be out of scope for a window manager. If Jamie's tip works out for you, I think that should not be part of xmonad. (But then, if you think it'd be really useful, go ahead.)
Perhaps what would be better would be a prompt module to modify xmonad's environment at runtime.
Hmmm. Or some way to "plug" a shell script that's executed instead of xmonad when you hit mod-q? For example, assume there's some magic that looks for ~/.xmonad/xmonad-wrapper first and, if it exists and is executable, execs this instead of /usr/local/bin/xmonad or ~/.xmonad/xmonad-$ARCH-$OS. Then you could write ~/.xmonad/xmonad-wrapper like this: #!/bin/sh eval $(ssh-agent -s) exec xmonad "$@" I'm a lazy slacker, so no patch, but from what I remember, the code restarting xmonad on mod-q isn't too complicated, and this may be a one- or two-liner.
Jamie's approach isn't truly general: if anything happens to that ssh-agent, then you're up the creek without a paddle.
Little bit OT, but did this *ever* happen to you? Ciao, Kili --
If you want to send mail, use sendmail. ;-) Und wenn es fix gehen soll? If you want something to fix, use postfix? ;-) -- Ralf Döblitz und Thomas Bliesener

On Mon, Mar 31, 2008 at 10:47:46PM +0200, Matthias Kilian wrote:
Jamie's approach isn't truly general: if anything happens to that ssh-agent, then you're up the creek without a paddle.
Little bit OT, but did this *ever* happen to you?
I don't know. I do know that the last time I started X, I had ssh-agent xmonad in my .vncrc/xstartup which had the result that when xmonad restarted, the ssh-agent disappeared. The SshAgent module allows me to rectify the situation without restarting my vncserver. -- David Roundy Department of Physics Oregon State University

On 31/03/2008, David Roundy
On Mon, Mar 31, 2008 at 10:47:46PM +0200, Matthias Kilian wrote:
Jamie's approach isn't truly general: if anything happens to that ssh-agent, then you're up the creek without a paddle.
Little bit OT, but did this *ever* happen to you?
I don't know. I do know that the last time I started X, I had
ssh-agent xmonad
in my .vncrc/xstartup which had the result that when xmonad restarted, the ssh-agent disappeared. The SshAgent module allows me to rectify the situation without restarting my vncserver.
I really fail to see what this has to do with a window manager. As has been pointed out: eval $(ssh-agent -s) Really is an adequate solution, and has worked for me for years. Why it doesn't work for you, I don't know, although polluting xmonad with it seems wrong to me. -- Thomas Adam

On Mar 31, 2008, at 17:11 , David Roundy wrote:
On Mon, Mar 31, 2008 at 10:47:46PM +0200, Matthias Kilian wrote:
Jamie's approach isn't truly general: if anything happens to that ssh-agent, then you're up the creek without a paddle.
Little bit OT, but did this *ever* happen to you?
I don't know. I do know that the last time I started X, I had
ssh-agent xmonad
in my .vncrc/xstartup which had the result that when xmonad restarted, the ssh-agent disappeared. The SshAgent module allows me to rectify the situation without restarting my vncserver.
Odd. I would expect xmonad to restart with an exec() syscall (execProcess?), which shouldn't cause ssh-agent to exit. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Mon, Mar 31, 2008 at 08:25:10PM -0400, Brandon S. Allbery KF8NH wrote:
Odd. I would expect xmonad to restart with an exec() syscall (execProcess?), which shouldn't cause ssh-agent to exit.
I thought the same and I'd like to know the answer to this, too. Has anyone discovered it? -- Mike

droundy:
Hi all,
I'm sending this rather than pushing, since we're close to a release. It's a new module to automatically start an ssh-agent, if one isn't running. I expect to find it useful. The reason for this is that the ordinary mechanism for starting a single ssh-agent for an X session doesn't seem to be working for me. And starting xmonad with `ssh-agent xmonad` does no good, because the ssh-agent exits as soon as I restart xmonad.
David
Sat Mar 29 11:49:11 CDT 2008 David Roundy
* add SshAgent module, to start ssh-agent when needed.
Do you want to push this, now the release is out?

On Mon, Mar 31, 2008 at 11:03:24AM -0700, Don Stewart wrote:
droundy:
Hi all,
I'm sending this rather than pushing, since we're close to a release. It's a new module to automatically start an ssh-agent, if one isn't running. I expect to find it useful. The reason for this is that the ordinary mechanism for starting a single ssh-agent for an X session doesn't seem to be working for me. And starting xmonad with `ssh-agent xmonad` does no good, because the ssh-agent exits as soon as I restart xmonad.
David
Sat Mar 29 11:49:11 CDT 2008 David Roundy
* add SshAgent module, to start ssh-agent when needed. Do you want to push this, now the release is out?
Folks seem to think it shouldn't go in. David

On Mar 31, 2008, at 14:17 , David Roundy wrote:
On Mon, Mar 31, 2008 at 11:03:24AM -0700, Don Stewart wrote:
droundy:
Hi all,
I'm sending this rather than pushing, since we're close to a release. It's a new module to automatically start an ssh-agent, if one isn't running. I expect to find it useful. The reason for this is that the ordinary mechanism for starting a single ssh-agent for an X session doesn't seem to be working for me. And starting xmonad with `ssh-agent xmonad` does no good, because the ssh-agent exits as soon as I restart xmonad.
David
Sat Mar 29 11:49:11 CDT 2008 David Roundy
* add SshAgent module, to start ssh-agent when needed. Do you want to push this, now the release is out?
Folks seem to think it shouldn't go in.
I'm still confused as to the problem you are solving with this. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Mon, Mar 31, 2008 at 02:44:00PM -0400, Brandon S. Allbery KF8NH wrote:
I'm still confused as to the problem you are solving with this.
I just want to have an ssh-agent running in xmonad. The ssh agent needs to be able to define environment variables in xmonad's environment, if it's to be visible to new terminals that are brought up. This module allows me to start up an ssh-agent in this way. It also allows me to start a new agent if there isn't an existing agent running, or if I'm forced to start xmonad from the command line because xmonad crashed. -- David Roundy Department of Physics Oregon State University

On Mar 31, 2008, at 14:50 , David Roundy wrote:
On Mon, Mar 31, 2008 at 02:44:00PM -0400, Brandon S. Allbery KF8NH wrote:
I'm still confused as to the problem you are solving with this.
I just want to have an ssh-agent running in xmonad. The ssh agent needs to be able to define environment variables in xmonad's environment, if it's to be visible to new terminals that are brought up. This module allows me to start up an ssh-agent in this way. It also allows me to start a new agent if there isn't an existing agent running, or if I'm forced to start xmonad from the command line because xmonad crashed.
And how do the other suggestions not help with this? -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Mon, Mar 31, 2008 at 03:41:45PM -0400, Brandon S. Allbery KF8NH wrote:
On Mar 31, 2008, at 14:50 , David Roundy wrote:
I'm still confused as to the problem you are solving with this.
I just want to have an ssh-agent running in xmonad. The ssh agent needs to be able to define environment variables in xmonad's environment, if it's to be visible to new terminals that are brought up. This module allows me to start up an ssh-agent in this way. It also allows me to start a new agent if there isn't an existing agent running, or if I'm forced to start xmonad from the command line because xmonad crashed.
And how do the other suggestions not help with this?
They don't allow me to start a new agent if there isn't an existing agent running. Maybe this doesn't matter. -- David Roundy Department of Physics Oregon State University
participants (8)
-
Brandon S. Allbery KF8NH
-
David Roundy
-
Don Stewart
-
Jamie Webb
-
Joachim Breitner
-
Matthias Kilian
-
Michael F. Lamb
-
Thomas Adam