LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-20-2017, 11:38 AM   #1
snowfun87
LQ Newbie
 
Registered: Jul 2017
Posts: 1

Rep: Reputation: Disabled
How do I set up this SSH tunnel?


Hi everyone,

I am having a really hard time setting up an SSH tunnel. I have looked at tutorials and how-to pages everywhere, and I find the man pages confusing. I am wondering if someone can provide me with the command to do what I am trying to do. I will be as detailed as possible.

I have a server running behind a NAT device that I can SSH to on an unconventional port (1106). The reason for this is we have a lot of development servers behind the same NAT and we have to have different SSH port forwarding for each one. I want to run gdbserver on this machine and connect to it from my client workstation. I want gdbserver to run on port 9160 on this machine behind the NAT. Since I don't have access to the NAT router, I can't set up port forwarding to access this port on the server, so I need an SSH tunnel. I want to be able to point my gdb client to port 9161 on my local workstation, and I want this to be forwarded over SSH to port 9160 on the server, using port 1106 for SSH. Here is the command I have been trying:

ssh -L 9161:localhost:9160 admin (at) my-server (dot) mydomain (dot) com -p 1106 -N
It seems like this should work. But I keep getting the error:

bind: Cannot assign requested address

And if I try to connect to port 9161 on localhost, I get an error:

channel 1: open failed: administratively prohibited: open failed

and the connection is closed immediately. I definitely am listening to port 9160 on the server, but it is acting as if we are getting a connection refused or something. When I look at wireshark, I don't see any kind of attempt to connect to the server whatsoever. So most likely there is something wrong with my command.

Any advice?
Thanks in advance.
 
Old 07-20-2017, 11:45 AM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
That looks like it should work, maybe the server you're connecting to doesn't allow unprivileged users to set up forwarding?

Could you set up a reverse tunnel initiated from my-server.mydomain.com to your local machine?

Last edited by suicidaleggroll; 07-20-2017 at 11:49 AM.
 
Old 07-20-2017, 11:52 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,084
Blog Entries: 3

Rep: Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665
The only thing that might be incorrect might be the order:

Code:
ssh -L 9161:localhost:9160 -p 1106 -N admin (at) my-server (dot) mydomain (dot) com
used@hostname comes last always, unless there is a remote command also.
 
Old 07-20-2017, 12:00 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,983

Rep: Reputation: 5678Reputation: 5678Reputation: 5678Reputation: 5678Reputation: 5678Reputation: 5678Reputation: 5678Reputation: 5678Reputation: 5678Reputation: 5678Reputation: 5678
Welcome to LinuxQuestions.

If the tunnel is connecting to the remote ssh server itself then using localhost is valid. The problem could be a IPV4/6 issue. You can also try:

Code:
 ssh -4 -p 1106 -N -L 9161:localhost:9160 admin@my.server.com
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH Reverse Tunnel - ~/.ssh/config - PHP marcelp1 Linux - Newbie 1 05-28-2014 01:49 AM
Initiate ssh tunnel to connect to ssh? brianmcgee Linux - Security 2 09-07-2011 11:07 AM
How do I set up an ssh tunnel through a http proxy? wilko Linux - Networking 2 03-10-2010 02:05 PM
setting up an ssh soxy or local ssh tunnel from within an ssh soxy Mangenius Linux - Networking 0 03-05-2007 04:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration