Solved

How to send email remotely using SSH tunnel

Posted on 2008-10-01
30
1,732 Views
Last Modified: 2013-12-17
I frequently use a public library in my town, and the firewall there prevents outgoing email from Outlook Express. I am trying to work around this using an SSH tunnel. I was able to configure the tunnel and can connect with no problems, but when I attempt to use OE to send I get "Your server has unexpectedly terminated the connection. Possible causes for this include server problems, network problems, or a long period of inactivity. Account: 'Home', Server: 'localhost', Protocol: SMTP, Port: 2525, Secure(SSL): No, Error Number: 0x800CCC0F". I have configured OE with server localhost and SMTP port 2525 (my tunnel is configured to forward local port 2525 to my mail server port 25) . I connect to the tunnel, then launch OE, but the message above is what I get. Help please...
0
Comment
Question by:Limozine
  • 14
  • 11
  • 5
30 Comments
 
LVL 7

Expert Comment

by:mchkorg
Comment Utility
That sounds good. Let's check.
When your tunnel is up, open  a "cmd" terminal and write "telnet localhost 2525"
If no answer, we have to fix your tunnel
If you get an answer like:
220 mail.yourhost.org ESMTP Postfix (Debian/GNU)
Then a server responded, so the problem is with outlook express.

(I think about something else : OE might be using your proxy setting, even for localhost connections ? To be sure, remove from IE your proxy configuration to prevent OE from using this setting silently)


0
 

Author Comment

by:Limozine
Comment Utility
Ok..I ran the "telnet localhost 2525" command and got: "Unable to connect to remote host: Connection refused".

If it helps, my mail server host has enabled jailed shell. Is that sufficient to open the tunnel correctly?
0
 
LVL 7

Expert Comment

by:mchkorg
Comment Utility
No, the fact that you can't connect from the beginning of the tunnel means your tunnel is not working.

How do you open it ? or think you open it ?
putty ? command-line openssh ?
0
 

Author Comment

by:Limozine
Comment Utility
Oops, forgot to mention that I'm not connecting to the internet via proxy, in IE or otherwise.
0
 

Author Comment

by:Limozine
Comment Utility
I've been connecting (or attempting to connect) using Putty. When I get "connected" it says

"Using username "myusername".
Authenticating with public key "imported-openssh-key"
Last login: Thu Oct  2 08:19:51 2008 from xx.xxx.xx.xxx
[myusername@hostname ~]$
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
> .. to work around this using an SSH tunnel.
wher do you issue the ssh command?
Do you use local or remote port forwarding?
0
 
LVL 7

Expert Comment

by:mchkorg
Comment Utility
How did you declare your port forwarding in putty ? send a screenshot
0
 

Author Comment

by:Limozine
Comment Utility
Screenshot from Putty SSH forwarding screen attached.
putty.jpg
0
 
LVL 7

Expert Comment

by:mchkorg
Comment Utility
It looks good.
I guess you entered the right thing in the "proxy" sub-menu because you're able to connect to the ssh server.

By the way (but I doubt this will be the solution), you can forward to 127.0.0.1 as I guess 74.5... is your ssh server and mail server. 127.0.0.1 means in this context "localhost from the end of tunnel's point of view". Try this - just in case.

Let's sum up:
- putty can connect
- the port mapping is correctly written (try with 127.0.0.1)
- no proxy misconfiguration
- BUT : telnet localhost 2525 doesn't reach anything
Maybe your local port 2525 is already bound to something before you start the ssh/tunnel.

1) check your bound ports before starting the tunnel (netstat, sysinternals - probably the one named "tcpview")

2) Try something else, not 2525

3) Just in case, you're not trying to reach your 2525 port from another computer ? (as it's bound to localhost unless you check "local ports accept conn.... from other hosts")

I'm running out of ideas after that...

4) does the POP mapping work ?

5) mmm, I read again your 1st post : talking about SSL SMTP. You're not messing up with port 465 ?
0
 

Author Comment

by:Limozine
Comment Utility
Thanks for all of the suggestions. I couldn't get it working, but I did find an acceptable workaround:

Since I use about ten different email addresses to send/receive, going to ten webmail interfaces just wasn't an option for me. I wanted all of my mail in one place, hence the need to use Outlook Express. So...went to my Google mail (gmail) help center and realized gmail could be set up as an IMAP account in OE. I followed the instructions, and now I can send email straight from OE! The only negative is that I have to use my Gmail account for any sending I do, but at least I can finally get it all in one place and send from one centralized interface.

I'd still like to know how to get the tunnel working, though...
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
> Ok..I ran the "telnet localhost 2525" command and got:
silly question: you did that on the remote site within the putty session?

As you opend a connection to 74.x.x.x on the remote site, did your remote site allow this connection?

Or in short words: which computer should make the connection to 74.x.x.x and which one runs OE, which one runs putty?
0
 

Author Comment

by:Limozine
Comment Utility
Not a silly question at all...I'm new to this ssh/putty stuff, so I'm quite capable of running things backwards.

I ran the telnet localhost 2525 command on the remote site from within the active putty session, yes. Should I be running it from a DOS prompt on my laptop?

74.x.x.x is the IP address for my mail server (which I am identifying as the remote computer), which is a shared host but my hosting company has supposedly configured to allow jailed ssh access. My laptop is the local computer and the one running both putty and OE, and the one from which I'm attempting to launch the tunnel.
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
> I ran the telnet localhost 2525 command on the remote site from within the active putty session
then you need to configure "remote" instead of "local" port forwarding
0
 
LVL 7

Expert Comment

by:mchkorg
Comment Utility
> Ok..I ran the "telnet localhost 2525" command and got:

start this from your client computer, not inside ssh the session (ie, at the end of the tunnel)


0
 

Author Comment

by:Limozine
Comment Utility
>> Ok..I ran the "telnet localhost 2525" command and got:

>start this from your client computer, not inside ssh the session (ie, at the end of the tunnel)

Ok, I started the Putty ssh session, then attempted the "telnet localhost 2525" command from a DOS command prompt (via Start, Run) on the client computer (my laptop). Here's what I got:

Connecting to localhost...Could not open connection to the host on port 2525: Connect failed"
0
Promote certifications in your email signature

Has your company recently won an award or achieved a certification? They'll no doubt want to show it off. Email signature images used to promote certifications & awards can instantly establish credibility with a recipient and provide you with numerous benefits.

 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
try&error, try&error, try&error, ....

can you please describe unambigious which computer can connect to 74.... port 25 for sue (please test before answering) and which computer needs to connect to it using your ssh tunnel.
 
0
 

Author Comment

by:Limozine
Comment Utility
Ok...here is my scenario. I'm sitting in the library, using my laptop to connect to the internet. I can receive email from any of my mail accounts using Outlook Express, but I can't reply or send. I'm assuming the library's ISP or firewall is preventing this. I've heard I can create an SSH tunnel to my mail server to work around this. My mail server IP is the 74.xxx number above.

I found instructions on the internet for creating an SSH tunnel using Putty. I followed the instructions, and you can see the configuration I used in the image posted on 10/3 (above). When I open Putty and load this connection, it appears to create the tunnel. I get a confirmation that the public key has been accepted and I'm logged in. To what, I'm not sure...I don't understand port forwarding. I only followed the instructions on the web site I found.

Regardless of whether I run the telnet localhost 2525 command in the SSH shell after connecting or in a DOS prompt locally, it fails.
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
> I've heard I can create an SSH tunnel to my mail server ..
do you have access to the mail server other than port 25 (SMTP)?

> .. and you can see the configuration ..
please reread my questions http:#22662014

in short:
  - which computer has full access to the mail server
  - which computer runs putty
  - which computer do you connect to with putty
  - which computer does not have full access to mail server
  - which computer runs your MUA
0
 

Author Comment

by:Limozine
Comment Utility
>do you have access to the mail server other than port 25 (SMTP)?
I don't know if I have access to the mail server other than port 25. My hosting provider gave me jailed shell access and told me to use port 2222 to connect to the mail server, so I configured the first page of Putty this way (under basic options).

> which computer has full access to the mail server
the laptop has jailed shell access

>which computer runs putty
the laptop

> which computer do you connect to with putty
I am connecting to the mail server by double-clicking on the putty icon (on the laptop) and loading the ssh tunnel session.

 >which computer does not have full access to mail server
I suppose the laptop, since I can connect to the server through the tunnel but I still can't send email through OE once connected

>which computer runs your MUA
laptop

The laptop is running both putty and OE. When I speak of establishing an SSH tunnel, I am referring to double-clicking on the putty icon on the laptop and loading the session i've pre-configured.

0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
> > which computer has full access to the mail server
> the laptop has jailed shell access

and

> >which computer does not have full access to mail server
> I suppose the laptop, since I can connect to the server through the tunnel but I still can't send email through OE once connected

hmm, could you please make a decission which one is the truth, as these 2 questions are alternate, obviously
may be I still missunderstand something, but these questions are alternate, so far ...
0
 

Author Comment

by:Limozine
Comment Utility
I have been told by my hosting company that I have jailed shell access on port 2222. I can only assume this is true. I know I can double-click on putty (on my laptop) and load the tunnel and I get a terminal window telling me it is authenticating the public key. Then I get a $ prompt. Does this mean I have "full" access? I have no idea. If I have full access, I would think I could send email via OE, but I can't. That is as much truth as I know.
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
> .. told by my hosting company that I have jailed shell access on port 2222
ok, seems to be hard for you to describe your environment and where your keying in what ....

So I assume following:
  1. you are somewhere (connected to a network somehow) with your laptop
  2. you successfully connect with putty to your mail server's jailed shell account
  3. from within putty's remote shell (that on the mail server) you can successfully send and
      receive mails from 74.xxx
  4. you can receive mails wherever you're with your laptop from 74.xxx
  5. you want to send mail wherever you're with your laptop's OE

then you need to have configured local forwarding for example on port 2525 to the remote IP 74.xxx port 25,
then point OE to use localhost port 2525 for sending mails
If that does not work, most likeley one of the assumption 1. - 5. (see above) are not true.
0
 

Author Comment

by:Limozine
Comment Utility
> ok, seems to be hard for you to describe your environment and where your keying in what ....
Sorry, I've tried to be as specific as I can. I don't know how else to express my scenario.

>So I assume following:
 > 1. you are somewhere (connected to a network somehow) with your laptop
true

  >2. you successfully connect with putty to your mail server's jailed shell account
true

  >3. from within putty's remote shell (that on the mail server) you can successfully send and
      receive mails from 74.xxx
I don't know how to do this...I've never attempted to send/receive from within the shell itself

 > 4. you can receive mails wherever you're with your laptop from 74.xxx
true

 > 5. you want to send mail wherever you're with your laptop's OE
yes

0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
now we need to verify 3. from my assumtion first.
please login to you mail server and issue following commands:

  uname -n

remeber the name you get and use it for FQDN below
now key in following:

telnet 74.xxx 25 <
0
 

Author Comment

by:Limozine
Comment Utility
I tried it...what is it supposed to do? I was left with a > prompt.
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
damn, I missed the final EoMail,
please add following right behind the line with the quit command:

EoMail

Anyway, it should have work and send a mail to you, does it?
0
 

Author Comment

by:Limozine
Comment Utility
Ok, I got:

Trying 74.xx.xx.xx...
Connected to FQDN (74.xx.xx.xx).
Escape character is '^]'.
220-FQDN ESMTP Exim 4.68 #1 Wed, 08 Oct 2008 13:56:55 -0500
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
Connection closed by foreign host.
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
does this mean that the connection was closed immediately after it prints the 220 messages?
0
 

Author Comment

by:Limozine
Comment Utility
Yes
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
Comment Utility
then you have to ask your hoster what are the requirenebt to allow a connection
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now