LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   SSH Port Forwarding Sneakiness (https://www.linuxquestions.org/questions/linux-networking-3/ssh-port-forwarding-sneakiness-413912/)

lmcilwain 02-10-2006 02:16 PM

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.

Heaven Fire 02-10-2006 02:29 PM

Hello,Is anybody here?

pnellesen 02-10-2006 03:31 PM

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...)

lmcilwain 02-10-2006 05:28 PM

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.

pnellesen 02-10-2006 07:58 PM

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:p )

lmcilwain 02-10-2006 11:27 PM

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.

lmcilwain 02-13-2006 09:03 AM

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.

lmcilwain 02-13-2006 09:55 AM

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]#

lmcilwain 02-14-2006 06:11 PM

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>" "M:DIGEST-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 :)

emetib 02-14-2006 07:29 PM

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.


All times are GMT -5. The time now is 07:18 AM.