LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-30-2018, 07:35 PM   #1
danmartinj
Member
 
Registered: Oct 2009
Posts: 117

Rep: Reputation: 1
Problems Setting up SSH IP Forwarding Question


I apologize in advance for asking a question about ssh port forwarding as I know there are many many examples online but I simply have not figured out an answer to my specific problem yet after spending half a day on it. Seems like what I am trying to do should be simple.

Basically I have a remote machine which I have full creds on running SSH and a webserver on its localhost port 8080. At first I tried tunneling X11 over ssh and using Firefox but it is way too slow.

Then I thought what if I can get SSH to listen on that remote host port 80 and have it forward me localhost:8080 so I would basically just open my client web browser, connect to that remote server:80 and then get forwarded to locahost:8080. So far the commands I have used are not working. I assume this should be possible.

Any advice would be greatly appreciated.

R Joe
 
Old 10-30-2018, 08:00 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936
The basic syntax to forward a local port on the server via ssh is:
Code:
ssh -L destination_port:localhost:source_port my_user@my_server
In the case of forwarding a web server the URL on your client computer would be
Code:
localhost:destination_port/desired_web_page

Last edited by michaelk; 10-30-2018 at 08:29 PM.
 
Old 10-30-2018, 10:47 PM   #3
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,382

Rep: Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761
An alternative is to use the '-D' option to ssh and set your local browser to use a SOCKS proxy, which is way quicker than running a remote browser instance over the tunnel. If you are concerned about DNS leakage from your local system, then you will want your remote system to also perform DNS lookups.
 
Old 10-31-2018, 11:47 AM   #4
danmartinj
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 1
I appreciate the help everyone supplied, however that information was pretty much exactly what I already found online. For my specific case, using CentOS the main big issue was the -R port forwarding was not binding on all interfaces. To enable it I had to do two things:

1. change ssh configuration to enable GatewayPorts then restart SSH
2. explicitly enable 0.0.0.0

This link explains further: https://superuser.com/questions/5885...open-to-public

R
Joe
 
  


Reply



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
Problems forwarding X with ssh crisostomo_enrico Solaris / OpenSolaris 4 10-08-2007 04:18 PM
Samba ssh port forwarding question.. brianbek Linux - Networking 1 01-18-2006 09:56 PM
ssh port forwarding question lmcilwain Linux - Networking 4 09-29-2005 02:32 PM
ssh port forwarding (tunneling?) question podollb Linux - Software 4 10-20-2004 01:12 AM
A little question to an SSH guru (port forwarding) J_Szucs Linux - Software 3 11-01-2003 07:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:12 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