[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: SMTP over SSH



> 
> What I'd like is to have a way to send traffic from my end on 2525 (or
> something else that isn't blocked) and have it go to port 25 on my mail
> server. What I had in mind, though I admit that I don't know if it's
> possible, is to establish a regular old SSH connection on port 22, then
> somehow 'bind' ports 22 and 25 on both ends. So that as far as the
> school firewall is concerned, I'm using SSH, but I'm actually sending to
> and from port 25 on each of the machines.
> 

I use this script to do exactly what you want. Sending mail to port 1125
on my local box automagically goes to my SMTP server on port 25.  Just
change your.mail.host and username to match your setup.
Could probably use some cleanup, but it works.  :)


#!/bin/sh
#
# Start or stop the SMTP SSH Tunnel
#
# Written by Jeremy Brooks
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin

sshflags="-2 -N -f -L"
host=your.mail.host
username=your_username
tunnel=1125:$host:25

case "$1" in
    start)
    	echo -n "Starting SMTP tunnel: "
	su $username -c "ssh -o KeepAlive=yes $sshflags $tunnel $host && echo '
SMTP tunnel.'"
	;;

    stop)
    	echo -n "Stopping SMTP tunnel: "
	kill $(ps -ef | grep ssh | grep $host | awk '{print $2}') && echo "
smtp_tunnel."
	;;

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: