Solved

Forward SSH from port x to port y using Apache

Posted on 2014-09-11
10
344 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
  • 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
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

856 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