LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to connect a remote host via ssh behind proxy (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-connect-a-remote-host-via-ssh-behind-proxy-4175464810/)

swaggerlee 06-05-2013 06:30 AM

how to connect a remote host via ssh behind proxy
 
HI all

here is the situation... let say

i deliver code to my client who is outside my network with ip 122.122.122.122 (say)

now i can connect my client via ssh with IP i.e 115.115.115.115 (say) direct connection from server room

but what i need to know is how can i connect to my client from my desk from my computer (ip 192.168.100.116) which is behind a squid proxy server.

waiting for possible solutions

Hope i described my problem briefly

sunilpopaliya 06-05-2013 07:01 AM

you want access 115.115.115.115 or 122.122.122.122 from your local system ??

I think you have a firewall between your local system to your data center right?


sunil

swaggerlee 06-05-2013 07:15 AM

@ sunil

i want to connect 122.122.122.122 from my local system

i have a proxy connection

sunilpopaliya 06-05-2013 07:22 AM

can you update output of tracert 122.122.122.122 from your local system?

Still i have doubt regarding your question. i want to know that 115.115.115.115 is your server which is situated at your data center right ? where 122.122.122.122 is placed ?


sunil

swaggerlee 06-05-2013 07:45 AM

Quote:

i want to know that 115.115.115.115 is your server

NO !!

actually it is a server with direct internet line having ip i.e 155.155.155.155 it is in our office placed in our server room

you don't have to provide proxy for browsing internet it runs on direct connection



Quote:

where 122.122.122.122 is placed ?
122.122.122.122 is our client computer IP address located some far away in same city

since our client has provided us with direct net connection (122.122.122.122). we can upload code to there machine through ssh and since i can't upload code from my desk machine as it is behind proxy so i need to go into server room and connet 122.122.122.122 from 155.155.155.155 via ssh

Quote:

can you update output of tracert 122.122.122.122 from your local system?
bash: command not found


HOPE i am clear !!!

sunilpopaliya 06-05-2013 08:28 AM

can you upload output of tracert 115.115.115.115 command from your local system ?


sunil popaliya

Turbocapitalist 06-05-2013 09:45 AM

Squid is for HTTP not SSH, so having Squid or not is irrelevant for your connection.

If you can log into 122.122.122.122 from the outside using and then from there to 192.168.100.116 again using SSH, you have several options. One is to chain ssh clients:

Code:

ssh -tt 122.122.122.122 ssh -tt 192.168.100.116
Another is to use netcat. It's a little more confusing, but provides you with a more direct connection.

Code:

ssh  -o 'ProxyCommand ssh %h nc 192.168.100.116 22' \
      -o 'HostKeyAlias=192.168.100.116' \
      user@122.122.122.122

There are other options and variations, including port forwarding. But like the above, they all depend on being able to ssh to 122.122.122.122 and from there to 192.168.100.116

swaggerlee 06-06-2013 12:51 AM

@ sunil bhai
Quote:

can you upload output of tracert 115.115.115.115 command from your local system ?
am on windows system ,how can i give you above output !!

@ Turbocapitalist

I think you didn't read my problem carefully

i want to connect 122.122.122.122 via ssh from 192.168.100.116 and i am using windows machine

plzz read above posts carefully and solvge my problem !!

sunilpopaliya 06-06-2013 01:07 AM

in windows machine go to command prompt and run this command.

I think turbocapitalist is correct. ssh has no concern with proxy.

ssh to 122.122.122.122 from your local machine you should have proper route and you should have proper permission at your client end.


sunil

a.abdulna 06-06-2013 01:13 AM

From local machine to able access your 115.x.x.x server through putty? then u are able access 122.x.x.x server also ( via 115)

swaggerlee 06-06-2013 01:30 AM

@ a.abdulna

yes i know i can do that via (115.x.x.x.) but i want to do it from my ip i.e 192.168.100.116 using putty
post something else !

sunilpopaliya 06-06-2013 01:33 AM

hey man,

He is telling you to ssh 115.115.115.115 from your local system. if it will work, you can do ssh to 122.122.122.122 also.


sunil

swaggerlee 06-06-2013 01:53 AM

@ sunil
the tracert output gives Request time out for 30 hops

as per ur comment can you suggest any "proper route" & "proper permission at my client end." so that i can connect 122.122.122.122 via ssh from my local machine

a.abdulna 06-06-2013 01:57 AM

Which proxy ur having? like ( firewall, router or any proxy script ). or just try like any route add from ur putty, # route add 122.x.x.x gw x.x.x.x

please explain me your scenario..

sunilpopaliya 06-06-2013 02:01 AM

It is better now to contact your Network admin to provide you proper access to connect your server because i don't know about your network architecture.

If any other query is there upload it.

sunil

Turbocapitalist 06-06-2013 02:06 AM

clarification
 
The above discussion is a little hard to sort out. Can you clarify exactly these machines?

A 115.115.115.115
B 122.122.122.122
C 192.168.100.116

Which one is your desktop?
Which one is the intermediary that you can already SSH to?
Which one is your destination which you can only reach via the intermediary?

swaggerlee 06-06-2013 02:41 AM

@ ALL

here is a scenerio ...

in my office server[X] having two ports one WAN port with direct internet line ip=115.x.x.x
another LAN port with ip=192.168.x.x

one proxy server[Y] with two port WAN ip=115.x.x.y & LAN ip=192.168.x.y running squid port listen on 3128

& let say 5 system connetced in lan using proxy to connect internet where my system ip is 192.168.100.116 (say)

now i have to deliver/upload code,content etc on my client computer who is outside of our network i.e. other city

basically i have to go into server room and i use server[X] to connet to my client since it in direct line, no need of proxy or firewall to browse internet or any... i can connetc to my client machine via ssh as they have also given us a didecated IP i.e. 122.x.x.x

but i want to connetc my client from my local desktop computer with ip=192.168.100.116 using windows xp and putty as client.


HOPE this is enough to explain

Turbocapitalist 06-06-2013 02:51 AM

It's still not clear to me.

A:115.115.115.115----B:122.122.122.122----C:192.168.100.116

If you are sitting at C and wanting to connect to A, but unable to make a direct connection yet able to connect to B, then you can follow the steps in #7 above, but substitute the right IP numbers for the ones I provided. There are two methods there, one chaining clients and the other using netcat. If you cannot use SSH to connect to the intermediary then there is likely no method that you can use to connect to the final machine either.

Squid has no relevance to or effect on SSH.

a.abdulna 06-06-2013 03:46 AM

Dear swaggerlee,


115 server accessing 122 via any VPN or 122 having public ip ? or is there any tunnel created for 115 server ? Actually we don't know your network architecture better you can contact your Network Administrator. He knows about your network traffic ways and restrictions and all. Maybe they will give you tunnel for this.

Cheers,

Abdul Salam

swaggerlee 06-06-2013 04:31 AM

Quote:

Originally Posted by Turbocapitalist (Post 4966415)
The above discussion is a little hard to sort out. Can you clarify exactly these machines?

A 115.115.115.115
B 122.122.122.122
C 192.168.100.116

Which one is your desktop?
Which one is the intermediary that you can already SSH to?
Which one is your destination which you can only reach via the intermediary?

192.168.100.116 is my local desktop machine(behind proxy)
115.115.115.115 is the intermediary which i can ssh
122.122.122.122 is the intermediary which i can only reach via the intermediary

Turbocapitalist 06-06-2013 04:37 AM

Quote:

Originally Posted by swaggerlee (Post 4966481)
192.168.100.116 is my local desktop machine(behind proxy)
115.115.115.115 is the intermediary which i can ssh
122.122.122.122 is the intermediary which i can only reach via the intermediary

Ok. If the user names are the same on 115.115.115.115 and 122.122.122.122 then here is the example from #7 above with the correct ip numbers:

Code:

ssh -tt 115.115.115.115 ssh -tt 122.122.122.122
Or

Code:

ssh -o 'ProxyCommand ssh %h nc 122.122.122.122 22' \
    -o 'HostKeyAlias=122.122.122.122' \
    user@115.115.115.115

Say which one works best for you.

sunilpopaliya 06-06-2013 06:33 AM

@swaggerlee

According to your output of tracert 155.115.115.155 command, you don't have access to this server from your local machine.

So ask your network admin to provide you ssh connection from your local machine to 115.115.115.115 server. I think if you are able to ssh 115.115.115.115 server, you may be able to access 122.122.122.122 server via ssh.

sunil

swaggerlee 06-06-2013 07:29 AM

i think m missing some info i'll be back soon with new scenario till then stay tune ....

swaggerlee 06-06-2013 08:27 AM

okk after reading my own post i realized that i have provided u info but missed a little bit i.e. as i said in my previous comments

Quote:

in my office server[X] having two ports one WAN port with direct internet line ip=115.115.115.115
another LAN port with ip=192.168.x.x
since m behind proxy so i can't connect ssh to server[X]with WAN IP 115.115.115.115 but i can connect ssh to server[X] with LAN IP 192.168.x.x

that implies that i'll be unable to connect my remote client from my local machine i.e. from 192.168.100.116---->122.122.122.122

so what next i need to do to establish connection

a.abdulna 06-06-2013 08:30 AM

you can connect your machine to X server with 192 series ip then try to connect 112 server, you are able to connect.
(open any terminal try to connect)

Turbocapitalist 06-06-2013 08:43 AM

Code:

+----------------+    +-----------------------------+    +----------------+
|        A      |    |            B                |    |      C        |
| 192.168.100.116<---->192.168.x.x  115.115.115.115<---->122.122.122.122 |
|                |    |                            |    |                |
+----------------+    +-----------------------------+    +----------------+

If your network layout is like the above and 115 *can* reach 122, and you can ssh to x.x, then you should be able to connect like this:

Code:

ssh -tt 192.168.x.x ssh -tt 122.122.122.122
If that is not the case, then LinuxQuestions can't really help you. You must seek further guidance from your network administrator first.

swaggerlee 06-07-2013 12:04 AM

HI All
yes i can connect nowwwww :) thank a lot buddies

but still !! what if want to connect directly i.e

Code:

+----------------+                    +------------------+
|        A      |        via        |        C        |
| 192.168.100.116<---------------------> 122.122.122.122  |
|                |        PROXY        |                  |       
+----------------+                    +------------------+

is there any way i can bypass using putty or linux terminal

sunilpopaliya 06-07-2013 12:09 AM

@swaggerlee

Still i am telling proxy has no concern with ssh.

Talk to your network admin regarding access you want from your local system.

sunil

a.abdulna 06-07-2013 01:09 AM

Dear Swaggerlee

You want to connect 112.x.x.x server directly ? Ask your Network Administrator to create a Tunnel between your local machine IP Gateway and Remote location Gateway like any Site to Site VPN using Router or Firewall. Then only your able to connect directly.

Cheers,
Abdul

swaggerlee 06-07-2013 03:40 AM

Okkkk thank you abdulna for reply and thank you all for holding your patience and giving a possible solution

and m sorry if i haven't clearly described my post earlier as i was confused too !!



well i do have another problems lets do it in new thread

3 cheers !!

swaggerlee


All times are GMT -5. The time now is 11:07 AM.