Updated remote script

Tomi Ollila tomi.ollila at iki.fi
Thu Jan 19 09:50:38 PST 2012


On Thu, 19 Jan 2012 11:24:32 -0500, Jesse Rosenthal <jrosenthal at jhu.edu> wrote:
> Dear all,
> 
> The big change in this script is that it uses dtach to set up a ssh
> socket, rather than suggesting that users do so themselves with the
> ControlMaster configuration option. This has the benefit of not making
> anyone mess with ~/.ssh, and not impacting your other ssh work. It also
> handles the issues of dead sockets on a laptop. (`ssh -Nf` seems like it
> *should* work too, but emacs hangs when it is used in a script.) The
> problem with this approach, of course, is that it requires dtach. A good
> solution would be to (a) make the use of reusable ssh sockets optional,
> and (b) allow it to use screen or tmux instead of dtach. Both would be
> pretty easy, and I'll work on it at some point. But I figured getting a
> two-year-old, broken script of the wiki would be a good first step.

Quick comments: "/tmp/notmuch_dtach.socket" is dangerous (and the _ssh).

either
        make directory /tmp/notmuch_`id -u`
        and chmod it to 0700
        and make sure you own it and it has right permissions.
or
        make directory for these sockets in $HOME and chmod that to 700
or
        just drop the socket in $HOME/.ssh (which should already be protected)

I personally use dtach, but basically never tmux nor screen ;)

--8<----8<----8<----8<----8<----8<----8<----8<--

In one of my scripts I do controlmaster connection in the following way:

ssh -O check "$rhost" || ssh -f -oControlMaster=yes $rhost sleep 18001
...
echo Backgroung ssh tunnel open for 5 hours.
echo SIGTERM pid `ps ax | awk '/180[0]1/ { print $1; }'` \
	In case that is not what you want.

and then  ssh -oControlMaster=no $rhost command args
to do the jobs...

> [0] http://notmuchmail.org/remoteusage/

more later..

> Best,
> Jesse


Tomi


More information about the notmuch mailing list