Search code examples
javajakarta-mailwirelesssshdport-number

JavaMail use of SSHD ports (when on open networks)


I have a (hopefully) simple question. Is it possible to use SSHD tunneling to securely access your Microsoft Exchange server using JavaMail when you are on a public network? I read about someone using SSHD tunneling to use airport wifi securely, can I do the same for my mail client?

Consider the following code fragment which currently allows me to log into my mail server (assuming correct username and password)

1 Properties props = System.getProperties();
2 props.setProperty("mail.imap.port", "993");
3 Session session = Session.getInstance(props, null);
4 Store store = session.getStore("imaps");
5 store.connect(host, name, pass);

My question is on line 2, is port 993 on my machine or the mail server? Can I simple SSHD to my office using port 8080 and substitute 8080 for 993, thus using the secure tunnel I set up?

Note: to my knowledge I'm not encrypting any network traffic, and even if it is naturally encrypted by way of "secure wireless" I would still like an additional layer of protection. Thanks for taking the time to read


Solution

  • Port 993 is on the mail server. Unless you can ssh into the machine running your mail server, it's not going to be simple to set up the tunnel you need. If you can only ssh into your office machine, you would need a port on that machine that you can connect to and get to your mail server from there. You can use something like the netcat program to set up a series of tunnels, but again not that simple.