![]() The service file reconnects every 5 seconds. Additionally, if the service file notices the ssh session dies, it will restart it. tunnel2me script is a wrapper script for an ssh command that tries to auto-reconnect. ![]() We create a systemd service file that kicks off the tunnel2me script. If you skipped to this section, make sure you complete Step 1 from the section above or else you will only be able to connect to Ubuntu from starlord. ![]() Sidenote: if you are on the NAS you can connect via ssh -p 22022 Making It Persistent Connect from Windows PC to Ubuntu via this command: ssh -p 22022 I picked 22022 as the magic number to use when we want to connect, but you can pick anything. Now what is localhost:22 from Ubuntu’s perspective, well thats just its own ssh session. Step 2.Start reverse ssh tunnel from Ubuntu to Starlord: ssh -p password ssh -f -N -T -R : 22022:localhost:22 -R command :22022:localhost:22 means that when anyone connects to to 22022 on starlord they will be connected to port 22 localhost on Ubuntu. Important:Completing this step is very important otherwise we will only be able to connect from the NAS (see Sidenote in step 3) If you were sshed into the linux host, this restart is too quick for you to actually be disconnected from the ssh session, so do not worry. Usually it goes above X11 Forwarding directives. Then restart the sshd service:Įdit the file to make sure it has “GatewayPorts yes” anywhere in the file. Step 1.Make sure that the linux host (starlord) has “GatewayPorts yes” in /etc/ssh/sshd_config. Lets do a proof of concept and make sure we can connect up like this, with some simple linux command. Proof of Concept & Prepare Linux hostīefore creating the scripts that kick-off the tunnel. Starlord is reachable SSH host, which can be reached by Ubuntu and other locations. The Ubuntu VM can be any server you are trying to reach that’s behind a NAT or firewall (that at least allows outbound connections). This article was written in mind for the topology & hostnames above, however it can be applied to any similar layout. Note, with the current default HyperV settings the Ubuntu VM is unreachable by anything in the network but it can reach anything (my Windows PC, the Switch, Starlord, and the internet). This by passes the tunnel and the need to create an external interface. Then I will be able to SSH into my Ubuntu VM thru starlord. Goal: Setup Reverse SSH tunnel from my Ubuntu VM to a Linux host in my network (or any network). I currently use HyperV KVM console to access the Ubuntu VM, which is very limiting as I have to use the UI, I can’t copy-paste between and its a small resolution. I have the option to create an external interface via HyperV to resolve that issue, however, it is having a hard time creating that interface. I cannot SSH into that Ubuntu VM because its using the default networking which creates a NAT. My Issue: I have a Ubuntu VM running on my Windows 11 via HyperV virtualization.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |