SSH Sendmail Configuration

Bill Farrow & Mike Pilone

Introduction


This method was suggested for SMTP servers that do not allow connections from localhost. Since the SSH tunnel normally connects to the SMTP server via SSH, then attempts to connect to the SMTP daemon, the connection appears as though it is from localhost. The exact email that pointed out the problem was:

I have been using this [ssh tunneling] method for a several months and one day it came
unstuck. My hosting service provider which I was using for POP and SMPT (via
the ssh tunnel) changed something at their end and the SMPT server stopped
accepting mail from their localhost.  I'm not sure if it was deliberate or
not.  So I had to find another way to get mail out !

I am now using the "sendmail" transport via ssh, which might be even more
secure than SMPT because it doesn't open any ports on your local machine.
Perhaps others would be interested ?

Prerequisites

  • Be sure to follow the general HOWTO here. This section only modifies the SMTP settings, but nothing else.

Shell Scripts

A simple shell script will be required. The script connects to the remote mail server and directly executes sendmail on that server, therefore not attempting to connect to the sendmail daemon. Download the script and make it executable, chmod u+x sshsendmail.sh.  Open the script in an editor (kwrite), and edit the variables SSH_USERNAME and SSH_SERVER. The username should be the username that you use to open an ssh connection to the mail server. This may not be the same as your POP3 or SMTP username. The mail server is the domain name (or IP) of your mail server. For now, it is assumed that the mail server is running the SSH daemon.


Configuring KMail



Launch KMail. Open the configuration dialog by clicking Settings->Configure KMail. Click on the second icon in the configuration dialog, the Network settings. Add a Sendmail
transport and change the "Location" field to /path/to/sshsendmail.sh
KMail SMTP Dialog
(Click to Enlarge)


Thats it. KMail is now configured to use the tunnel for POP and sendmail for SMTP.  As I mentioned in the beginning of the article, you need to setup SSH for DSA/RSA for full functionality.

Links

SSH Tunneling HOWTO: http://www.slac.com/~mpilone/projects/kde/kmailssh/index.html
KDE: http://www.kde.org
KMail: http://pim.kde.org/components/kmail.php
OpenSSH: http://www.openssh.com/
IBM DeveloperWorks OpenSSH Key Management: http://www-106.ibm.com/developerworks/linux/library/l-keyc.html

Acknowledgments

Bill Farrow kde@arrowsreach.com
The KDE project and all the developers, translaters, artists, etc. involved.

Comments are welcome at mpilone@slac.com.
Authors: Bill Farrow, Mike Pilone (homepage)

Created: 04/30/03
Last updated: 04/30/03

Extra Info

All the images were created with KSnapshot, and manipulated with the Gimp. The web page was created with Mozilla Composer. The scripts were edited in JEdit. The icon set is Noia 0.95 and style Keramik on KDE 3.1 on SuSE 8.1. My keyboard was used for typing and my mouse for pointing 'n clicking.

All text and images are copyright Mike Pilone 2003. The article  is under a BSD license.