Mac OS X: Gnus -> remote Courier IMAP via ssh-agent
I finally learned how to get Gnus in XEmacs (installed in Mac OS X 10.1.4 via fink) to access my mail on a remote Courier IMAP server—from anywhere, even from within a firewall, using a password-free, ssh-agentized encrypted connection.
Key setup syntax recorded here.
<!— imported into MT from 2002 Radio entry via RE on 2003-12-10 —>
2005-06-15: Content of the now-offline wiki page:
2002-06-11: Recording another probably useful reference:
Using nnimap with courier - and other pitfalls
2002-05-28:
I got Gnus + Courier IMAP-ssl (on NetBSD) working a while back, satisfying the need to stop transmitting IMAP account info in the clear. It also worked fine tunneled through ssh, allowing me to get my mail at home from inside my company firewall that blocks imap ports 143 and 993 (ssl).
But the double whammy of ssh- ”and” ssl-encryption made mail reading too slow.
How to access a remote Courier IMAP server via ssh only?
(ssh-agent already allowing password-free shell login to remote box)
Doug Alcorn quotes Andi Hechtbauer:
It’s easier and more convenient of course to have your ssh keys and ssh-agent set up right (cf. ssh(1) “public-key cryptography”, ssh-agent(1), and ssh-add(1)) and just
(setq imap-shell-program '( "ssh -x -C remote.imap.host /usr/sbin/imapd" )) (setq gnus-secondary-select-methods '( (nnimap "host" (nnimap-address "remote.imap.host") (nnimap-stream shell) (nnimap-list-pattern ("INBOX" "mail/*")) ) ))in your .gnus.el; So you M-x gnus and it just opens a ssh connection and starts your imapd preauthenticated. No need for username and password at all.
But on opening gnus (oort 0.7cvs) in XEmacs (21.5.4), the correctly issued command hangs forever. Maybe a Courier IMAP-specific issue?
Will Yardley provided the Courier-specific clue I need:
From: Will Yardley Subject: Re: Pine, ssh and Cyrus imapd Newsgroups: comp.mail.pine Date: 2002-03-13 08:34:03 PST... what happens when you ssh to the machine with that command; ie: ssh hostname -q -l username exec /usr/sbin/imapd you want it to say something like: * PREAUTH Ready. i made this work with courier imapd by making /etc/imapd with this in it: zugzug% cat /etc/rimapd #!/bin/sh umask 077 /usr/bin/imapd 2> /dev/null Maildir otherwise it doesn't work because if you run the courier binary directly it sends stderr along with stdout (since it's not being run by courier's standard facilities). This didn't quite work, but incorporating the idea in my .gnus.el works!-- (setq imap-shell-program '( "ssh -C remote.imap.host imapd 2>/dev/null Maildir" )) (setq gnus-secondary-select-methods '( (nnimap "host" (nnimap-address "remote.imap.host") (nnimap-stream shell) (nnimap-list-pattern ("INBOX" "INBOX.Lists.*")) ;; optional: (imap-log t) ; put imap session trace in buffer *imap-log* (nnimap-expunge-on-close always) ) ))
Yes!

