]> git.cworth.org Git - notmuch-wiki/blob - remoteusage.mdwn
fcc on remote usage
[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 (<del>3</del>).
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 (<del>3</del>) If you don't want / cannot use password-free login,
36 [[This|remoteusage/124]] page provides yet another alternative.
37
38 ## Configure `ssh` on the client computer ##
39
40 Add this to your `~/.ssh/config`:
41
42     Host notmuch
43         HostName example.com
44         User remoteuser
45         ControlMaster auto
46         ControlPath ~/.ssh/master-%h@%p:%r
47         ControlPersist 15m
48         IdentityFile ~/.ssh/example.com.id_rsa
49
50 Replace `example.com` with your server. Replace `remoteuser` with the
51 username on the server.
52
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
56 latency.
57
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.
61
62 Please refer to `ssh_config(5)` man page for details.
63
64 ## Set up a wrapper shell script on the client computer ##
65
66 Save this to a file, for example `remote-notmuch.sh`, in your `PATH`:
67
68     #!/bin/bash
69     printf -v ARGS "%q " "$@"
70     exec ssh notmuch notmuch ${ARGS}
71
72 and give it execute permissons: `chmod +x remote-notmuch.sh`
73
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.)
77
78 ## Configure Emacs on the client computer ##
79
80 Add this to your `~/.emacs` to tell the Emacs client to use the wrapper
81 script:
82
83     (setq notmuch-command "/path/to/your/remote-notmuch.sh")
84
85 If you use Fcc and Notmuch older than 0.23, you may want to do something like
86 this on the client, to Bcc mails to yourself:
87
88     (setq notmuch-fcc-dirs nil)
89     (add-hook 'message-header-setup-hook
90         (lambda () (insert (format "Bcc: %s <%s>\n"
91                     (notmuch-user-name)
92                     (notmuch-user-primary-email))))))
93
94 Starting from 0.23, Fcc is also done through notmuch-command.
95
96 ## Problems ##
97
98 Some things probably won't work perfectly, and there might be some
99 unexpected mismatches between normal usage and this sort of usage. If
100 you're using this approach and run into any problems, please feel free
101 to list them here. And, of course, if you improve on any of these
102 approaches, please do edit this page and let people know!
103
104 If you have issues, you may want to try the
105 [[old remote usage instructions|remoteusage/old]] or
106 [[yet another alternative|remoteusage/124]].