LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 04-27-2024, 08:06 PM   #1
nedlud
LQ Newbie
 
Registered: Oct 2004
Posts: 24

Rep: Reputation: 0
How to establish ssh from remote firewalled PC to local machine, enabling local browsing on remote LAN


Apologies if the terminology is incorrect, suggestions for better thread title welcome.

I administer (a grand word for my amateur efforts) a server (oakdrum) on a friend's (christine) LAN, which is used to backup her laptop (x1-laptop), and for syncthing, DLNA server, samba etc.

She lives 500 miles from me. After initial setup at her house with physical access, I setup port forwarding on her router so that I could ssh into (oakdrum), and (x1-laptop) for remote assistance via vnc. Having done so, I could also access the web GUI (no telnet or ssh available) of her router from my machine (lutyens) with:

Code:
nedlud@lutyens:~ssh -v -D 24080 -f -C -q -N oakdrum
... and configuring a manual proxy in my browser:

Code:
Manual proxy configuration:
  SOCKS Proxy  127.0.0.1  Port 24080
      check the box for "SOCKS v5"
... then access her router GUI at 192.168.1.1 on my local machine (lutyens)

This week after a fault her ISP sent her a new router. She's tech-phobic, but swapped it out plug for plug with the broken one. She has WAN access with the default config of course, but (oakdrum) has a different IP so her backup doesn't work, and now I can't get to her LAN.

The limit of her capability is copy pasting a string in the terminal.

assume:
I will temporarily forward port 33022 on my firewall to port 22 on my machine, and enable password only ssh login.
My username on my machine (lutyens) is nedlud.
My dynamic dns is nedlud.dyndns.net


I'm after the cli string that she can use on her laptop (x1-laptop) to ssh to my machine (lutyens), and anything I need to run on (lutyens), such that I can browse to her router config page, and re-establish port forwarding.

MTIA.
 
Old 04-27-2024, 08:28 PM   #2
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,463
Blog Entries: 7

Rep: Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561
You probably want to use a reverse SSH session.

You'll get many hits if you search for it, but here's a random one which explains the basics of it: https://ryan.himmelwright.net/post/s...se-ssh-tunnel/
 
Old 04-27-2024, 11:33 PM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,330
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Quote:
Originally Posted by rkelsen View Post
You probably want to use a reverse SSH session.
Yes, that'd be the way to go. Have her system connect to yours using -R option.

Code:
ssh -f -N \
        -i ~/.ssh/some.key.ed25519 \
        -R 2222:localhost:22 \
        -l christine \
        lutyens.example.com
Much of that can actually be put in her ~/.ssh/config file so that she only has to type a 'ssh lutyens' or some other shortcut, and that can in turn be put in a script for a .desktop file to click on. For example:

Code:
Host lutyens lutyens.example.com
	HostName lutyens.example.com
	User christine
	RemoteForward 2222 localhost:22
	ForkAfterAuthentication yes
	SessionType none
	IdentitiesOnly yes
	IdentityFile /home/%u/.ssh/some.key.ed25519

Host *
	ServerAliveCountMax 3
	ServerAliveInterval 30
	ConnectTimeout 2
Then once that connection is established, connect almost the same as before, but to localhost instead of oakdrum and specify the port of the tunnel:

Code:
ssh -D 24080 -f -C -q -p -N 127.0.0.1
Setting up reverse tunnels is rather simple but not deceptively so.

Last edited by Turbocapitalist; 04-27-2024 at 11:46 PM. Reason: SessionType and ForkAfterAuthentication
 
Old 04-28-2024, 06:23 PM   #4
nedlud
LQ Newbie
 
Registered: Oct 2004
Posts: 24

Original Poster
Rep: Reputation: 0
Quote:
Yes, that'd be the way to go. Have her system connect to yours using -R option.
Thank you very much. Hoping it will go well and quickly when I do it for real, I have practised this from my laptop (on public wifi) to simulate, and a VM on my main machine, which I'll use for the real exercise, to avoid exposing my main machine, enabling password ssh, having to provide/change my password etc.

The only things I had to tweak were adding her username when setting up the tunnel for the browser, and specifying the port.

Substituting what worked in my practice run with the dummy hosts and users in the OP, this worked:

christine copy pastes:

Code:
christine@x1-laptop:~ssh -f -N -p 33022 -R 2222:localhost:22 nedlud@nedlud.dyndns.net
nedlud@nedlud.dyndns.net's password:
christine@x1-laptop:~
Then I:

Code:
nedlud@lutyens:~ ssh -D 24080 -f -C -q -N -p 2222 christine@127.0.0.1
christine@127.0.0.1's password:
nedlud@lutyens:~
I could then, with browser settings:

Code:
Manual proxy configuration:
  SOCKS Proxy  127.0.0.1  Port 24080
      check the box for "SOCKS v5"
...browse "from" (x1-laptop), proved by visiting whatismyip.com.

So I'm confident that when I do this for real, I'll be able to access her router admin page, which is what I need to achieve. Don't think I'm missing anything, and I'll mark as solved when it's done.

Thanks again!
 
Old 04-29-2024, 06:35 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,749

Rep: Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928
Just a FYI that you have posted your real username and URL which essentially points a neon target at your server. Changing ssh ports is not a real deterrent.
 
Old 04-29-2024, 01:43 PM   #6
nedlud
LQ Newbie
 
Registered: Oct 2004
Posts: 24

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
Just a FYI that you have posted your real username and URL which essentially points a neon target at your server. Changing ssh ports is not a real deterrent.

Thanks Michael, Good of you to take the trouble. However all host names, usernames and ports in my OP are dummies, though accurately describing the commands entered.

I hope to do this thing this evening, and assuming it's successful, I'll add a post describing everything, with "generic specifics", if that makes sense.
 
Old 04-29-2024, 07:29 PM   #7
memilanuk
Member
 
Registered: Sep 2010
Location: Washington state, USA
Distribution: Ubuntu among others
Posts: 68

Rep: Reputation: 2
Interesting scenario!

I've not a lot of direct experience with ssh tunneling myself... but would having something like tailscale installed on the respective machines help at all? That way they can all 'see' each other on a flat VPN network, with no port forwarding at the router level. Seems like it'd be near ideal for a use case like this...
 
Old 04-29-2024, 11:13 PM   #8
friendlysalmon8827
Member
 
Registered: Dec 2023
Distribution: Anfroid,Debian
Posts: 101

Rep: Reputation: 6
I'd strongly recommend that the OP go back through his original post and redact the host names and other potentially exposing information. It seems to me that the OP would be best served by investing in some high-quality uninterruptible power supplies a couple of good brands are CYBERPower and APC the latter of which is a synder electric product line.
 
Old 04-30-2024, 05:46 AM   #9
nedlud
LQ Newbie
 
Registered: Oct 2004
Posts: 24

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by memilanuk View Post
Interesting scenario!

I've not a lot of direct experience with ssh tunneling myself... but would having something like tailscale installed on the respective machines help at all? That way they can all 'see' each other on a flat VPN network, with no port forwarding at the router level. Seems like it'd be near ideal for a use case like this...
Thanks for the suggestion, but I don't want to use anything needing third party server, or proprietary (especially with it's roots in Google) if I can help it. I usually use vnc over ssh to provide remote assistance to (christine) so she has to do literally nothing to set up the connection. I'm experimenting with self hosted RustDesk, but haven't figured out how the ssh keys work yet.

Quote:
Originally Posted by friendlysalmon8827 View Post
I'd strongly recommend that the OP go back through his original post and redact the host names and other potentially exposing information.
As in https://www.linuxquestions.org/quest...6/#post6498905, all host and user names are dummies. Am I missing something?

Quote:
Originally Posted by friendlysalmon8827 View Post
It seems to me that the OP would be best served by investing in some high-quality uninterruptible power supplies a couple of good brands are CYBERPower and APC the latter of which is a synder electric product line.
I'm not seeing how that's directly relevant?

Christine won't be ready to do this for a few days, and when it's done I'll post full details.

Last edited by nedlud; 04-30-2024 at 05:47 AM.
 
  


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
[SOLVED] How to establish ssh tunnel from remote firewalled PC for VNC remote assistance? nedlud Linux - Networking 6 05-25-2023 11:30 AM
our LAN's proxy server is firewalled disabling a movie download..plz help rs_vijay Linux - Networking 2 11-01-2007 01:35 AM
Ssh connection to a firewalled machine. assasukasse Linux - Networking 10 06-20-2007 11:58 AM
Cannot SSH to remote firewalled terminal? ajeetraina Linux - Networking 1 06-14-2007 08:27 AM

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

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