This document describes how to get mail to your workstation in a very convenient way, nice when abroad using hot spots for an example.
Incoming mail is queued upon reception on your server
. Outgoing mail is queued on your workstation
. From time to time, when server
and workstation
can communicate, a crontab
processes those queues using the UUCP protocol over SSH : incoming mail is delivered to your mailbox on your workstation
and outgoing is sent for relaying by the server
's MTA.
This is a secure and unixish way to handle your mail.
Requirements
You need a server
with a permanent Internet connection, ready to accept mail for your domain. You need root
access on this machine.
You also need root
access on your workstation
.
I used the Postix MTA on both the server and the workstation. I tried to keep the Debian default on the workstation (Exim) but I did not manage to get it working : mail coming from UUCP was not delivered. So I switched to Postfix and it worked out of the box.
I use the Internet Site debconf configuration mode on server
and the Standalone configuration mode on workstation
.
Server configuration
server# aptitude install postfix uucp ssh
UUCP
You first need to tell the server
that worksation
exists for the UUCP protocol. Add the following lines to /etc/uucp/sys
:
system workstation
time any
port TCP
protocol t
remote-send ~
remote-receive /
Create yourself an UUCP login by adding the following line to /etc/uucp/passwd
:
user password
Check the permissions of this file, Debian defaults are perfect as usual and this password will be protected by an SSH key, but it is better to double check. Permissions should be -rw-r—– root uucp
.
postfix
must be configured to accept mail for your domain, and also for your workstation.
Add the following line to /etc/postfix/main.cf
to tell postfix
to read a transport file :
transport_maps = hash:/etc/postfix/transport
Create the file /etc/postfix/transport
to tell postfix
to use UUCP to deliver mail to your workstation :
workstation.domain.org uucp:workstation
Then run postmap /etc/postfix/transport
.
Add the following line to /etc/aliases
to tell that mail for you must go to your workstation :
you you@workstation.domain.org
Then run postalias /etc/aliases
.
All that's left is to restart postfix
:
server# /etc/init.d/postfix restart
Tests
Now try to send yourself some mail and check that it is queued in the UUCP spool /var/spool/uucp/workstation/D./
.
Client configuration
workstation# aptitude install postfix uucp ssh
UUCP
workstation
must know about server
. Add the following lines to /etc/uucp/sys
system server
call-login *
call-password *
time any
protocol t
address server.domain.org
port SSH
remote-send /
remote-receive ~
UUCP should go over SSH. Add the following in /etc/uucp/port
:
port SSH
type pipe
command /usr/bin/ssh -C -x -o batchmode=yes server
Tell UUCP about you login/pass in /etc/uucp/call
:
server user password
user
and password
should match what you told the server
.
SSH access to the server
You should now setup the SSH access to the server. The followings commands should generate a key pair, publish the public one on the server
and add it to the authorized login keys of user uucp@server
.
workstation# su - uucp
uucp@workstation$ ssh-keygen -t rsa
(do not enter a passphrase here)
uucp@workstation$ scp ~/.ssh/id-rsa.pub someuser@server
uucp@workstation$ ssh someuser@server
someuser@server$ su
server# mkdir ~uucp/.ssh && mv ~someuser/id_rsa.pub ~uucp/.ssh/authorized_keys
server# chmod 700 ~uucp/.ssh && chown -R uucp.uucp ~uucp/.ssh
server# exit
someuser@server$ exit
uucp@workstation$
What I did then was editing ~uucp/.ssh/config
and add some lines :
Host server
HostName server.domain.org
Port 22
(I use the port line because my SSH server runs on a non-standard port, but if you use port 22, you can omit it)
At this point, you should be able to login without entering a password :
uucp@workstation$ ssh server
uucp@server$
Now, set the command invocked by ssh
on server
by adding a command=
statement at the beginning of the declaration in the authorized_keys
file which should now read :
command="/usr/sbin/uucico -l" ssh-rsa <some junk which is the public key>
This connects uucp
on the client side directly to the uucico
pipe on server
.
If something goes wrong, tell me about it or fix this howto…
Syncing the UUCP queues
The following command should deliver your mail to your workstation.
uucp@workstation$ /usr/sbin/uucico -f -s server
You should see clues about this in your local mailbox of cours, in /var/log/mail.log
and in /var/log/uucp/Log
.
You can setup a crontab
to to this automatically :
uucp@workstation$ crontab -e
And add the following line to sync the queues every 5 minutes :
*/5 * * * * /usr/sbin/uucico -f -s server
Outgoing mail
The only remaining thing to do is to tell Postix to use UUCP to send outgoing mail. Add the following lines to /etc/postfix/main.cf
:
relayhost = server
default_transport = uucp
Final setup
Configure your mail client to poll your mail in /var/mail/<your_login>
and to send mail using localhost
. That's it!