]> git.cworth.org Git - notmuch-wiki/blob - remoteusage.mdwn
replaced /home/user with ~ and gave master socket
[notmuch-wiki] / remoteusage.mdwn
1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 # Using notmuch remotely #
3
4 ## Why? ##
5
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.
10
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.
15
16 ## What you will need ##
17
18 You will need to have the following items in place:
19
20 1. a working notmuch and `sshd` on one computer (let's call that
21 computer "server").
22
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
25 "client")
26
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.
30
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.)
34
35 ## Configure `ssh` on the client computer ##
36
37 Add this to your `~/.ssh/config`:
38
39     Host notmuch
40         HostName example.com
41         User remoteuser
42         ControlMaster auto
43         ControlPath ~/.ssh/master-%h@%p:%r
44         ControlPersist 15m
45         IdentityFile ~/.ssh/example.com.id_rsa
46
47 Replace `example.com` with your server. Replace `remoteuser` with the
48 username on the server.
49
50 The `Control*` options keep the connection open in the background to not
51 require authentication every time. The `ControlPersist` option defines
52 the connection timeout. These aren't strictly necessary, but reduce
53 latency.
54
55 The `IdentityFile` option may not be necessary depending on how you set
56 up public key authentication. This assumes you set up a separate key;
57 set the filename accordingly.
58
59 Please refer to `ssh_config(5)` man page for details.
60
61 ## Set up a wrapper shell script on the client computer ##
62
63 Save this to a file, for example `remote-notmuch.sh`, in your `PATH`:
64
65     #!/bin/bash
66     printf -v ARGS "%q " "$@"
67     exec ssh notmuch notmuch ${ARGS}
68
69 and give it execute permissons: `chmod +x remote-notmuch.sh`
70
71 Now you can run `remote-notmuch.sh new`, or other notmuch commands. You
72 can call the script anything you like. (You could also call it `notmuch`
73 or symlink `~/bin/notmuch` to it for transparent usage.)
74
75 ## Configure Emacs on the client computer ##
76
77 Add this to your `~/.emacs` to tell the Emacs client to use the wrapper
78 script:
79
80     (setq notmuch-command "/path/to/your/remote-notmuch.sh")
81
82 If you use Fcc, you may want to do something like this on the client, to
83 Bcc mails to yourself:
84
85     (setq notmuch-fcc-dirs nil)
86     (add-hook 'message-header-setup-hook
87         (lambda () (insert (format "Bcc: %s <%s>\n"
88                     (notmuch-user-name)
89                     (notmuch-user-primary-email))))))
90
91 ## Problems ##
92
93 Some things probably won't work perfectly, and there might be some
94 unexpected mismatches between normal usage and this sort of usage. If
95 you're using this approach and run into any problems, please feel free
96 to list them here. And, of course, if you improve on any of these
97 approaches, please do edit this page and let people know!
98
99 If you have issues, you may want to try the [[old remote usage
100 instructions|remoteusage-old]].