1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 # Using notmuch remotely #
6 It is hard to keep notmuch tags in sync across multiple instances of
7 notmuch, on multiple computers. Though you can do this with "notmuch
8 dump" and "notmuch restore", it is often preferable to be able to use
9 notmuch on a remote computer as if it were present on a local computer.
11 The following guidelines show how to accomplished this. It isn't
12 perfect, but it works pretty well, and allows one to access notmuch on
13 one computer, using only an Emacs client, a trivial shell script, and
14 some Emacs and ssh settings on another computer.
16 ## What you will need ##
18 You will need to have the following items in place:
20 1. a working notmuch and `sshd` on one computer (let's call that
23 2. a working notmuch emacs interface (of the same version as on the
24 server), `bash`, and `ssh` on another computer (let's call that computer
27 3. password-free login (public key authentication) from client to
28 server. [Here](http://www.debian-administration.org/articles/152) is a
29 good page on how to set it up (*).
31 4. a reasonably fast connection. (This isn't really *necessary*, but if
32 your connection is too slow, this won't be very pleasant to use, and
33 certainly won't seem transparent.)
35 (*) If you don't want / cannot use password-free login,
36 [[This|remoteusage/124]] page provides yet another alternative.
38 ## Configure `ssh` on the client computer ##
40 Add this to your `~/.ssh/config`:
46 ControlPath ~/.ssh/master-%h@%p:%r
48 IdentityFile ~/.ssh/example.com.id_rsa
50 Replace `example.com` with your server. Replace `remoteuser` with the
51 username on the server.
53 The `Control*` options keep the connection open in the background to not
54 require authentication every time. The `ControlPersist` option defines
55 the connection timeout. These aren't strictly necessary, but reduce
58 The `IdentityFile` option may not be necessary depending on how you set
59 up public key authentication. This assumes you set up a separate key;
60 set the filename accordingly.
62 Please refer to `ssh_config(5)` man page for details.
64 ## Set up a wrapper shell script on the client computer ##
66 Save this to a file, for example `remote-notmuch.sh`, in your `PATH`:
69 printf -v ARGS "%q " "$@"
70 exec ssh notmuch notmuch ${ARGS}
72 and give it execute permissons: `chmod +x remote-notmuch.sh`
74 Now you can run `remote-notmuch.sh new`, or other notmuch commands. You
75 can call the script anything you like. (You could also call it `notmuch`
76 or symlink `~/bin/notmuch` to it for transparent usage.)
78 ## Configure Emacs on the client computer ##
80 Add this to your `~/.emacs` to tell the Emacs client to use the wrapper
83 (setq notmuch-command "/path/to/your/remote-notmuch.sh")
85 If you use Fcc, you may want to do something like this on the client, to
86 Bcc mails to yourself:
88 (setq notmuch-fcc-dirs nil)
89 (add-hook 'message-header-setup-hook
90 (lambda () (insert (format "Bcc: %s <%s>\n"
92 (notmuch-user-primary-email))))))
96 Some things probably won't work perfectly, and there might be some
97 unexpected mismatches between normal usage and this sort of usage. If
98 you're using this approach and run into any problems, please feel free
99 to list them here. And, of course, if you improve on any of these
100 approaches, please do edit this page and let people know!
102 If you have issues, you may want to try the
103 [[old remote usage instructions|remoteusage/old]] or
104 [[yet another alternative|remoteusage/124]].