LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Problem setup SSH tunnel over multiple servers (https://www.linuxquestions.org/questions/linux-networking-3/problem-setup-ssh-tunnel-over-multiple-servers-347693/)

dussel 07-28-2005 12:02 PM

Problem setup SSH tunnel over multiple servers
 
Hello all,

I hope someone can fast give me some help what I do wrong ;-)

What I want to do are to build a SHH tunnel from my localhost to server1 (that i no problem) and when I get the wnat I build a SSH tunnel to server2, and when there build SSH tunnel to server3.
And with another terminal be able to ssh to my localhost and be forwarded directly to server 3.

I can not build the tunnel in "one command", I must build my tunnel i several steps because of the the end address is an internal-address and Server1 does not know that internal-address.

What I have done so far is

ssh -g -L 5436:localhost:22 server1.publicnet.com -l user

that brings me to server1 (no problems), the I want to continue from server 1 to server 2

ssh -v -L 5436:server1.publicnet.com:22 server2.localnet -l user

and from server2 to server3

ssh -v -L 1984:server2.localnet:22 server3.othernet -l user

But now when I test connect to my localhost:5436 then I end up only on server1

ssh -p 5436 user@localhost

What do I wrong???

it is not authentication problem, I have set up "key-authentication" and it works without problem. I have added "ForwardAgent yes" in my $home/.ssh/config

Please help!

Matir 07-28-2005 12:45 PM

Well, I'm not sure if this will work, but here's my guess:
Code:

localhost $ ssh -L2222:server2:22 server1
localhost $ ssh -L2223:server3:22 -p2222 localhost
localhost $ ssh -p2223 locahost

That final statement should connect you to server3.

dussel 07-28-2005 05:54 PM

That does not work! but...
 
Thanks for your replay,

unfortunatly does it not work with your solution, but you helped me to gt one step closer to end-server. when I do SSH to my local port is stopping at server 2 now ;-)
Yeah, then I am half the way to my goal...

No, had to modify your suggestion a littel.
So now am I using as follow:

from Localhost ---> server1
test
ssh -v -L 5234:server2:22 server1.publicnet.com -l user
ssh -v -L 5235:ip-for-server3:22 server2.localnet -l user

taht brings me directly to server2 when I ssh to localport 5234.

But it is still one more step to get to my server3, and I am really confused because I the most radical and desperate solution to get my tird step to work without any success. for example:

ssh -A -p 5235 server3.othernet
ssh -L 5236:localhost:22 server3 -l user

None of above lets me to ssh localhost port and direct send me to server3

So, I am greatfull over more suggestions how it can be solved because I biggin to get really confused over it....

Matir 07-28-2005 09:38 PM

What happens when you try to ssh to port 5235?

dussel 07-29-2005 04:07 AM

It is not looking so good when I do it server2, I get...

ssh: connect to address 127.0.0.1 port 5235: Connection refused

Matir 07-29-2005 08:51 AM

And server2 does have access to server3 on ssh port?


All times are GMT -5. The time now is 09:15 PM.