LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-10-2006, 03:16 PM   #1
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Rep: Reputation: 31
SSH Port Forwarding Sneakiness


Hello all,

I'm looking for a way to be able to be able to send my email through a remote server to a remote server so that I can be able to send mail succesfully. Sounds a bit spastic I know but here is my issue and my need for this.

At work I just got a new machine that doesn't entirely have full access to the web (something about increasing productivity). Well now when I used to be able to check mail on a TLS port I can't seem to do that anymore. I am however still able to ssh authenticate to my network at home. Since I am not running an smtp server on my home machine (not that my ISP would let me) I can't do a single port forward from my work machine to my home machine to be able to send mail successfully. I need to be able to send mail through my machine at home and have a port forwarded to the TLS port to the remote server that can actually send out the e mail. Here is an example:

1. Get an email from friend or family
2. Write response to said email
3. Click send
4. Mail is port forwarded using ssh to my machine at home
5. My machine at home has that particular port forwarded to aaa.bbb.ccc:587 so the mail gets sent on.

To me this sounds a bit far fetched so I am not even sure if it will work but just in case anyone has ever tried it out there, Im looking for some advice on how to go about doing it. Mainly my machine that I want to do this with is a linux machine and I am simply not sure how I can set it up to be able to constaly port forward to a specific port let alone and address and a port.

Thanks for any help or advice.
 
Old 02-10-2006, 03:29 PM   #2
Heaven Fire
LQ Newbie
 
Registered: Feb 2006
Posts: 3

Rep: Reputation: 0
Hello,Is anybody here?
 
Old 02-10-2006, 04:31 PM   #3
pnellesen
Member
 
Registered: Oct 2004
Location: Missouri, USA
Distribution: Slackware 12.2, Xubuntu 9.10
Posts: 371

Rep: Reputation: 31
I'm doing more or less the exact same thing you want to do, but I do have sendmail running on my home machine. My ISP doesn't allow me to send email out to the world directly, I have to setup sendmail to send to their email server first - so in my sendmail config file there's a line about "smarthost" (I think) that points to "myisp:25". Could you not also setup an ssh port to forward to aaa.bbb.ccc:587 instead of your home machine? (I'm not sure if that's allowed or not...)
 
Old 02-10-2006, 06:28 PM   #4
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
I did try setting up the ssh to port forward to that aaa.bbb.ccc:587 but didn't have any luck sending anything out via the mail client. I am not to familiar with sendmail so I am not sure where I would go to look for the config file. Mind giving me a general location of where yours is and I think Iw ill probably be able to find it from there.
 
Old 02-10-2006, 08:58 PM   #5
pnellesen
Member
 
Registered: Oct 2004
Location: Missouri, USA
Distribution: Slackware 12.2, Xubuntu 9.10
Posts: 371

Rep: Reputation: 31
Well, the first thing you may want to check is that your ISP does indeed let you send outgoing emails through their server - odds are they do. I'm far (VERY) from a sendmail expert, but the file in question on my machine is /etc/mail/sendmail.cf Note that you don't want to edit this file directly - the exact procedure has been outlined/described in MANY different places on this forum (HERE too). The only real reason I'm using sendmail is that it was pretty easy to setup w/ the Slackware install - there are other mail servers out there that some people claim are MUCH easier to configure than sendmail (squirrelmail is one I read alot about.) Assuming your ISP does allow mail relaying, you might also try creating an SSH port from :25 on your work machine to whatever your ISP's relay url/port is, and bypass the sendmail thing altogether (I THINK this is possible, but I'm no SSH expert either )

Last edited by pnellesen; 02-10-2006 at 09:13 PM.
 
Old 02-11-2006, 12:27 AM   #6
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
I will try to give it a shot tomorrow and see how well I do. I will also try and speak with my ISP to see if they allow this. I will post again at worse, on Monday.
 
Old 02-13-2006, 10:03 AM   #7
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
My ISP for whatever reason was dodging whether or not they would allow me to use there smtp server as a relay server for my e mail so I decided that I am going to try using the smarthost option and seeing how that works since I don't really like my ISP anyway .

For this particular server I was using Yellow Dog Linux 3.0.2 and I didn't see anywhere where it had a mail directory to configure sendmail which made me think it wasn't installed or they were using a different' server for sending mail. Since I partitioned the disk wrong, I decided to try FC4 for the Mac and after a weekend of trying to install this I finally got the server up and running late last night. I am going to take a look at the instructions you posted and see if I can get this up and running and will update you as soon as I have something.
 
Old 02-13-2006, 10:55 AM   #8
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
So I tried to update my sendmail.mc file which seemed simple enough since the smarthost entry was in the first few lines. I changed that to the mailserver I wanted to use for mail relay but I couldn't figure out how or where to specify the TLS port to use so I just put a :587 at the end of it. I don't know if that will work exactly or not but it seems to be common to do that.

I then tried to update the sendmail.cf file using the m4 command but I got the following errow when I did it (as root and as my username):

[root@FC4FW]# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
/etc/mail/sendmail.mc:10: m4: Cannot open /usr/share/sendmail-cf/m4/cf.m4: No such file or directory
[root@FC4FW]#
 
Old 02-14-2006, 07:11 PM   #9
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
I found another FAQ (http://www.cri.ch/linux/docs/sk0009.html) that gave me a step by step of how to set up smtp relay for sendmail.

The additional steps I took were as follows:

Added the following to the sendmail.mc file:
define(`SMART_HOST', `your-smtp-server')
FEATURE(authinfo)dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')
define(`ESMTP_MAILER_ARGS', `TCP $h 587')
Updated the sendmail.cf file
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

Defined my account info in the AuthInfo file:
AuthInfo:<your-smtp-server> "U:<your-smtp-user>" "P:<your-smtp-password>" "MIGEST-MD5"
Im not sure if the "M:" is correct since the server that I would be logging into would be over TLS port 587 and usually just does a login challenge and nothing more. I don't know if I just need to specify login.

Updated the authinfo.db file
makemap hash /etc/mail/authinfo < /etc/mail/authinfo

Created a userdb for header rewriting
user:mailname foo@bar.com
Created the userdb.db file
makemap btree /etc/mail/userdb.db < /etc/mail/userdb

Sendmail, Tested, and got the following output:
[root@FC4FW mail]# /usr/sbin/sendmail -bv root@localhost
root@localhost... deliverable: mailer local, user root

[root@FC4FW mail]# /usr/sbin/sendmail -bv lovell.mcilwain@gmail.com
lovell.mcilwain@gmail.com... deliverable: mailer relay, host foo.barr.com, user user@foo.com

This would leave me to belive that this was successful from what I see in the output. But then I take a look at /var/log/maillog and find the following:

Feb 14 18:37:04 localhost sendmail[12272]: k1EEWlrh009414: to=<lovell.mcilwain@gmail.com>, ctladdr=<root@localhost.localdomain> (0/0), delay=09:04:17, xdelay=00:00:01, mailer=relay, pri=945174, relay=foo.bar.com [11.222.333.444], dsn=5.0.0, stat=Service unavailable
Feb 14 18:37:04 localhost sendmail[12272]: k1EEWlrh009414: k1ENb3vE012272: sender notify: Service unavailable

I thought the tutorial has gotten me closer to where I wanted to be but can anyone else tell me what else Im missing to get this to work properly? The things I noticed off the top of my head were:

1.The authentication method is wrong but I can't see any documentation that states that the entry "M:login" will work.
2. It still looks like the return mail is showing as root@localhost.localdomain when I thought the usersdb.db file was supposed to take care of this. Did I need to restart sendmail or re run the m4 command to update that there is now a usersdb.db in existance?

3. Could this be an issue of not specifying the port number correctly for sendmail to talk with the relay server properly?

I know this was a bit lengthy but any help is appreciated
 
Old 02-14-2006, 08:29 PM   #10
emetib
Member
 
Registered: Feb 2003
Posts: 484

Rep: Reputation: 33
hey, i don't know about sendmail at all. yet, this link http://www.freebsd.org/doc/en_US.ISO...ail-using.html looks like it would be good for your trials.

close to the bottom of the page you'll see "Section 14.11.8". click on it.

you could look at doing a modification to the sendmail.cf. changing it's pickup and maybe putting a pipe in it.

good luck.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH Port forwarding WRSpithead Linux - Networking 1 04-18-2005 05:09 AM
Port forwarding for ssh Adriaan Linux - Networking 1 03-08-2004 10:11 AM
Ssh port forwarding? J_Szucs Linux - Networking 1 10-29-2003 05:42 AM
Help with Port Forwarding for SSH mi6 Linux - Networking 6 07-29-2003 01:46 PM
SSH port forwarding tarballedtux Linux - Networking 2 05-29-2002 08:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration