Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here's the Diagram

Server A ----> Server B <----- Laptop

So basically Server A and Laptop can connect to Server B directly but you can't establish a connection from Server A to Laptop directly, so we setup a reverse ssh tunnel from Server A to Server B so that Laptop can connect to Server A thru a tunnel setup by Server A. So right now ssh to Server A from Laptop is solved.

Now, I have an app setup in Server A that I need to access thru port 443 on the Laptop, how can I do that?

share|improve this question

3 Answers 3

A bit of a guess what you have already:

start with the reverse tunnel:

serverA:~ $ ssh -R 22:localhost:10022 serverB

then from the Laptop connect to serverB too and connect a local forward to the port you defined in the reverse forward:

laptop:~ $ ssh -L 10023:localhost:10022 serverB

if I understood you correctly something like that is the part you already did. And now to the last part:

connect to localhost on the port you used in the local forward, this sends all the packages directly to serverA, specify another port forward so your application can connect to serverA

laptop:~ $ ssh -p 10023 -L 10443:localhost:443 localhost

if your Application needs to connect to 443 and can't used another port as for example 10443 which I used in the example you'll have to do the last connection as root:

laptop:~ $ su -
laptop:~ # ssh -p 10023 -L 443:localhost:443 user@localhost

or

laptop:~ $ sudo ssh -p 10023 -L 443:localhost:443 user@localhost

Some explanations:

  • "443:localhost:443" gets resolved at the remote end.... so it's actually serverA
  • "user@" is the user needed to login to serverA, if not needed before its needed now as you locally are root now
  • "localhost" is resolved locally so it's actually the Laptop.

HTH Marcel

share|improve this answer
    
very helpful, thanks so much –  pinoyskull Sep 28 '10 at 3:04

If you want the -R forwarded port on server B to be reachable from server A, you need to specify a bind-address on server B to the left of the remote port. E.g., if B has the address 1.2.3.4 and you are connecting from the laptop:

laptop:~ $ ssh -R 1.2.3.4:10443:127.0.0.1:443 server-b

This will forward port 10443 on server-b to 443 on the laptop. If you want to use port 443 instead, logon to server-b as root.

share|improve this answer
    
right now Server A is doing a reverse tunnel to Server B, so in Server B i can access Server A thru ssh on port 10222, how do I connect directly to Server A from my Laptop using that setup? –  pinoyskull Sep 28 '10 at 1:40

If you have SSH access to Server A, then do something like ssh -L 8443:localhost:443 user@serverA should work. Then you can use https://localhost:8443 to connect.

share|improve this answer
1  
I have no direct connection to Serer A from Laptop that's why we setup a reverse tunnel from Server A to Server B –  pinoyskull Sep 27 '10 at 22:09
    
After setting up the tunnel to A, you do the one above. –  Wouter de Bie Sep 28 '10 at 6:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.