Solved

Forward SSH from port x to port y using Apache

Posted on 2014-09-11
10
351 Views
Last Modified: 2014-09-12
One of my Ubuntu servers is running Atlassian Stash which runs an additional SSHD instance on a nonstandard port.  Unfortunately, I need to connect via a DIFFERENT nonstandard port that is in the range I got opened on my ISP's firewall. As far as I can tell, I cannot change what port that uses. :(

Can Apache forward SSH from port x to port y for me?  I really don't want to need to install HAProxy just to do this.

Thanks!
0
Comment
Question by:Daniel Wilson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
10 Comments
 
LVL 12

Expert Comment

by:Kent W
ID: 40317940
I'd suggest using "balance", a very simple port redirect / load balancer that simply listens on one port, forward to another.  It doesn't care if it's local, remote, etc.

Works very well, is very easy to admin.

http://www.inlab.de/balance.html
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40317963
I'm checking that out, mugojava.  I need something simple!
0
 
LVL 12

Accepted Solution

by:
Kent W earned 300 total points
ID: 40318018
Once you have it installed, it's quite simply as easy as, say if you want to redirect port 23 to 22 -

balance 23 localhost:22

Open in new window


You can then hit port 23 with ssh

many more options, but that simple.

It does not run as a service, but I just create a "balancing.sh" script, and place it in the rc.local, so it fires up at startup.

BalanceNG ($) will run as a service I believe.  Never tried the paid product.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 62

Assisted Solution

by:gheist
gheist earned 100 total points
ID: 40318095
SSHd on port 22 can do all port forwarding you need.
0
 
LVL 23

Assisted Solution

by:savone
savone earned 100 total points
ID: 40318172
You can use iptables to redirect the port.

iptables -t nat -A PREROUTING -p tcp --dport 2222 -j REDIRECT --to-port 2222
0
 
LVL 12

Expert Comment

by:Kent W
ID: 40318298
I use more Centos, so just checked and balance is available via apt-get.

Quite simply
sudo apt-get install balance

Then pump in the command I gave above with the appropriate ports, and you are redirecting.
Just make sure your firewall is not blocking your selected port.
0
 
LVL 62

Expert Comment

by:gheist
ID: 40318299
~.(enter)
R 2222 127.0.0.1:22222 <enter>
0
 
LVL 23

Expert Comment

by:savone
ID: 40318314
Apt-get is a Debian package manage not available on centos without work.
0
 
LVL 12

Expert Comment

by:Kent W
ID: 40318381
OP is using Ubuntu. It's Debian.
0
 
LVL 32

Author Closing Comment

by:Daniel Wilson
ID: 40320425
Thanks to all of you!  I got started with balance, so I think I'm OK with that.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Linux boot cd to do hardware report on PC? 3 99
Can't "Unset" Proxy in Apache headers for PCI compliance... 4 94
http response code 3 38
Linux 6 32
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

734 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