Solved

Forward SSH from port x to port y using Apache

Posted on 2014-09-11
10
361 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
Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

 
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

623 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