|
LinuxFocus article number 330
http://linuxfocus.org
|
|
|
|
|
by Guido Socher (homepage)
About the author:
Guido really likes UUCP e-mail because it is a solution
that integrates perfectly with a Linux computer.
|
uucpssh.org: UUCP e-mail for Linux fans
Abstract:
In the windows world incomming mails are received via POP3 or IMAP
and outgoing mails are sent directly via SMTP. This split setup
can cause all kind of headaches especially if you are using
different ISPs all the time.
UUCP is an old protocol but it is really a clever solution to send
and receive e-mail. On top of that uucpssh.org offers some really
flexible forwarding features.
_________________ _________________ _________________
|
Introduction
uucpssh.org offers a really good e-mail solution for Linux
users. It combines UUCP e-mail transport with the security of
SSH and offers on top of that some flexible forwarding options.
UUCP is very old protocol and was originally used to copy any type of files between Unix systems. Thus the name: "Unix to Unix Copy". These early computer systems were not permanently connected via a network. Instead dialup modem connections where used to exchange data in regular time intervals. UUCP is ideal
to transport things that have a "batch job" characteristic such as e-mail or news.
Today UUCP is no longer used for general file tranport. It is however still
very good for e-mail, especially if you are frequently on the move.
When you are connected to a wireless Lan at the air port you can
send and receive mails in exactly the same way as from your network
at home. You don't have to change a single configuration parameter.
The technical part
Now lets see how you configure e-mail over uucp trough an SSH tunnel.
For those who are now wondering how to configure this under XP or 98 or ...
You need Linux. It is a solution specifically for Linux or
Unix systems in general.
An e-mail system in general consists of MUAs (mail user agents), the
program where you type in the mail and read it, and MTAs (mail transport
agents) also known as mail-servers. Examples of MUAs are mutt, Kmail,
Thunderbird, etc... MTAs transport the mail from one computer to the
other. Since UUCP/SSH are a transport protocols it is clear that we
use UUCP/SSH in this solution to interconnect the MTAs.
In other words we will configure a local mail server on our Linux
computer to use UUCP instead of SMTP for both incomming and outgoing
e-mail.
UUCP is the transport and hides the fact from the MTA that we are
not always connected to the internet. It takes care of the transporting
of mails as a batch.
Finally SSH is the protocol we use to encapsulate UUCP and connect to uucpssh.org.
To use uucpssh.org UUCP e-mail you need to own a complete domain because
the routing is done on a per domain name basis. The local MTA on your Linux
machine will then sort the mail for the different users.
Since uucpssh.org sorts the mails only on a per domain basis
you have full flexibility when it comes to the user part (the stuff before the "@" sign).
You can create as many aliases and users as you like.
What's a MX domain?
A domain name is something like linuxfocus.org, that's probably clear to most
people. To have a domain you need a DNS server. The internet works at the protocol
level not with names but with numbers, IP addresses. A DNS server translates a name
into an IP address and then this number is used to establish the connection between
to hosts (e.g web servers or mail servers).
If you want to have to physically differnt hosts for web pages and ftp then you have
to give them different names. E.g linuxfocus.org and ftp.linuxfocus.org.
This is however not the case e-mail because there is a special DNS entry for mail called
MX (Mail Exchanger). You can have your webpages at one host (linuxfocus.org)
and you can have you e-mail at uucpssh.org and reach it also via linuxfocus.org (or [email protected]).
In other words when you move to uucpssh.org then you move only the MX domain.
Setting it up, MTA part
We will start with the configuration of the MTA.
In this article we discuss exim, postfix and sendmail. Any of them is
good for UUCP.
Exim 3
Add this to the main section (at the top) of the exim.conf file:
trusted_users = uucp
primary_hostname = your.own.mail.domain
local_domains = your.own.mail.domain
In the transport section add:
# Transport for uucp
uucp:
driver = pipe
user = nobody
command = "/usr/bin/uux -r - ${host}!rmail ${pipe_addresses}"
return_fail_output = true
At the beginning (!) of the router section add:
# Router for uucp (which domains are uucp domains):
# This must come before lookuphost!
uucphost:
transport = uucp
driver = domainlist
route_list = * uucpssh byname
Test the configuration with the command exim -bV and then
restart exim. (/etc/init.d/exim restart)
Exim 4
Add to the exim.conf the following entries:
trusted_users = uucp
primary_hostname = your.own.mail.domain
domainlist local_domains = your.own.mail.domain
domainlist relay_to_domains =
hostlist relay_from_hosts = 127.0.0.1
In the transport section add:
# Transport for uucp
uucp:
driver = pipe
user = uucp
command = "/usr/bin/uux -r - ${host}!rmail ${pipe_addresses}"
path = /usr/local/bin:/usr/bin:/bin
return_fail_output
At the beginning of the router section add:
# Router for uucp (which domains are uucp domains):
# This must come at the beginning of the router section
uucphost:
transport = uucp
driver = manualroute
domains = ! +local_domains
route_list = * uucpssh byname
Test the configuration with the command exim -bV and then
restart exim. (/etc/init.d/exim restart)
Sendmail
Sendmail uses a m4 pre-processor based configuration system.
The m4 configuration system might not be included in the same
package as sendmail it self. Check the CDs of your distribution
your might need to install a package called something like
"sendmail-cf".
Create a new sendmail-uucp.mc file in the cf directory for
sendmail (probably /usr/lib/sendmail-cf/cf):
#divert(-1)
# `This is config sends outgoing mail via uucp
#
# to generate a sendmail.cf out of this .mc file
# use the sendmail sources
# and run m4 thisfile.mc > sendmail.cf.'
divert(0)
include(`../m4/cf.m4')
VERSIONID(`UUCP, without DNS')
undefine(`BITNET_RELAY')
undefine(`DECNET_RELAY')
undefine(`UUCP_RELAY')
OSTYPE(`linux')
MASQUERADE_AS(your.own.mail.domain)
MASQUERADE_DOMAIN(localdomain)
MASQUERADE_DOMAIN(localhost)
# ` needed if you use an internal domain that does not exist: '
FEATURE(`masquerade_envelope')
FEATURE(always_add_domain)
# ` read allowed domains from cw file: '
FEATURE(use_cw_file)
FEATURE(local_procmail)
# `important for uucp:'
FEATURE(accept_unresolvable_domains)dnl
# `the /etc/passwd entry: mail:*:8:12:mail:/var/spool/mail:'
define(`confDEF_USER_ID',``8:12'')
define(`confSAFE_QUEUE',`True')
define(`confDELIVERY_MODE',`background')dnl
# 'replace mfic by the UUCP system name of your ISP:'
define(`SMART_HOST',uucp-uudom:uucpssh)dnl
define(`confSERVICE_SWITCH_FILE',/etc/service.switch)dnl
define(`confHOSTS_FILE',/etc/hosts)dnl
define(`UUCP_MAILER_MAX',1024000)dnl
MAILER(procmail)dnl
MAILER(local)dnl
MAILER(smtp)dnl
MAILER(uucp)dnl
Compile it with the command:
m4 sendmail-uucp.mc > sendmail.cf
Copy the sendmail.cf file to /etc and restart sendmail with
/etc/init.d/sendmail restart
In the /etc/service.switch file you should use:
hosts files
aliases files
Postfix
See also Postfix FAQ (http://www.postfix.org/faq.html#uucp-tcp)
on using UUCP as the default transport.
In the /etc/postfix/main.cf add:
relayhost=uucpssh
default_transport=uucp
and in /etc/postfix/master.cf you should have the following entry:
uucp unix - n n - - pipe
flags=F user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
Setting it up, UUCP part
The uucp software is available from http://www.airs.com/ian/uucp.html however check the CDs of your linux distribution first. All major distributions
have packages for it. If you stil want to install from the source then watch out. UUCP
(at least until version 1.07) uses some rather strange path naming conventions. It installs
e.g executables to /usr/lib/uucp. All packages from the distributions have fixed those problems.
Having said that: gentoo linux installs in version 1.06 the files to the right directories (/usr/bin, /usr/sbin, /etc/uucp) but the compiled in path is still wrong in a few cases.
I will further down describe a few tips how to debug problems with the uucp installation.
For the configuration of uucp you should have in the directory /etc/uucp/ at least the
following files:
- config -- general configuration file (if all path are correctly comiled
into uucp then this file can be empty)
- call -- "a password file" for uucp login to uucpssh.org
- port -- config file for the type of connection to
use
- sys -- defines all uucp systems that your system knows
of
In the uucp world every installation of uucp should have a name. This name is checked
when two uucp systems handshake at the beginning of their communication.
uucpssh.org is called uucpssh (all lower case) and your system name is what you define
when you create an account at uucpssh.org. In the example below it will be mailtux.
Edit file /etc/uucp/sys and add at the end:
system uucpssh
myname mailtux
time any
address main.uucpssh.org
port SSH
protocol t
remote-send /
remote-receive ~
chat ""
Edit file /etc/uucp/port and add at the end:
port SSH
type pipe
command /usr/bin/ssh -C -x -o batchmode=yes [email protected]
Edit file /etc/uucp/call and add:
uucpssh mailtux your-random-string-get-it-from-uucpssh.org-admin-page
Now check your configuration by running the command "uuchk". Correct any syntax errors if
needed.
To forward mails to uucpssh.org we will use ssh as user uucp. Make sure there is a user
defined in /etc/passwd with the name uucp and that it has a valid home directory.
Check also that uucico has the s-bit set and belongs to the user uucp. The program, when
executed by any user must always run as if it was executed by the user uucp. The same
is valid for uux:
-r-sr-sr-x 1 uucp uucp 225008 Mar 7 2002 /usr/sbin/uucico
-r-sr-xr-x 1 uucp uucp 93920 Mar 7 2002 /usr/bin/uux
Setting it up, SSH part
We must now generate a DSA key for ssh and upload it to the uucpssh.org admin page.
How to do this is also described on the admin page. I just repeat it here.
- Become uucp user (su - uucp)
- Execute ssh-keygen -t dsa
- Do not give any password.
- upload the content of ~uucp/.ssh/id_dsa.pub to your uucpssh.org admin page
Testing
Send a mail to somebody outside of your host and check that it
is queued via uucp with the command
uustat -a
The mail should have ended up in the /var/spool/uucp/uucpssh/C./ and /var/spool/uucp/uucpssh/D./
directories.
Run
uulog -40
to see what happened. Check the log files in /var/log for your
mailer and /var/log/uucp for uucp. Those files can give you some clues if
things don't work. If the above did not work then the fault is somewhere
in the configuration of your MTA (mail server).
If above test was OK then test the SSH connection. Login as user uucp (su - uucp as root) and
run.
ssh [email protected] -v
Accept the server's RSA key and you should see a uucp prompt (something like "Shere...").
Finally we test the sending out of our queued uucp mail with the command:
/usr/sbin/uucico -x 11 -S uucpssh
The -x11 adds the maximum amount of debug information. If anything goes wrong
then you should find clues in /var/log/uucp/Debug.
To test incomming mails send a mail from outside to [email protected]
and then fetch the mails from uucpssh.org with the command:
/usr/sbin/uucico -x 11 -S uucpssh
Again check /var/log/uucp/Debug for problems. Incomming mails are first queued in
/var/spool/uucp/uucpssh/X./ and then automatically send to your MTA via the command
/usr/sbin/uuxqt and /usr/bin/rmail. gentoo linux had here a bug: It was looking for uuxqt
under /usr/lib/uucp/ and was expecting the configuration files in /usr/conf/uucp. I fixed
those gentoo specific faults by creating some softlinks.
Check the log of your MTA and you should see that the mail was received and delivered to you.
Daily use
Once installed correctly there is not much to do. You just run
/usr/sbin/uucico -S uucpssh
uulog -5
to exchange mail with the Internet. I prefer to have total
control over that and I run it manually via a script but you
can also add
/usr/sbin/uucico -S uucpssh
to /etc/ppp/ip-up and it will be executed every time you connect
to the Internet.
Links
Enjoy UUCP mail!
2005-01-14, generated by lfparser_pdf version 2.51