Listening port putty tunnel does not work - linux

The goal is to connect to my home computer from outside. The ISP blocks all the ports (and demands $$$ for business package with static ip address), so simple port forwarding on home router does not work.
I have used putty to tunnel a listening port to a remote server: R2221:###.###.###.###:2221 (to make things simpler, the test server is a simple ftp server running on my home windows machine) (the entire ip address has to be specified -- with OpenSSH 1.0 running on the linux box wildcard address results in refusal of connection) (GatewayPorts are set to on).
Netstat -a confirms that port 2221 on the linux box is open and listening. However, whenever I try to connect to that port, it simply hangs. Command line ftp client says "connected to ###.###.###.###" and that's it. Running netstat again shows dozens of opened connections to port 2221, all coming from my windows box (I tried using browser as well as command line ftp client).
Which step am I missing?
Tried with RDP, VNC and FTP -- all of them hang, all of them connect when connecting through my home network (or my home router).
EDIT The setup is as follows:
PC 1 (windows) has FTP service running on port 2221. It uses PuTTY to tunnel a listening port to PC 2 (linux). PC 2 does show listening port when running netstat. Connecting to port 2221 on PC 2 either form PC 2 or from PC 3 results in hanging.
EDIT 2 Aaaand it worked. Using 127.0.0.1 instead of the remote machine's ip address was what corrected it. Thanks a lot.

Are you sure your -R command is correct? From what you say I suppose the command should be R2221:127.0.0.1:2221. The -R ssh option in form of port:host:hostport does the following: it opens port port on the remote side and forwards the connection to that port to local address host:hostport, and this connection is made from the local machine.
To make your local machine (the one that is running ssh client, e.g. PuTTY) connect to your local FTP server running on the same machine, use 127.0.0.1 as an address.
It also explains why you see a strange behaviour: when you actually connect to xxx.xxx.xxx.xxx:2221, it forwards the connection to the same address xxx.xxx.xxx.xxx:2221 and you get some kind of a loop.

Related

Cannot access to WSL2 port opened via IPv6 from Windows host

I have a node-server running at WSL2 Ubuntu-20.04.
netstat -tulpn in WSL shows the following ports:
The ports specified as 0.0.0.0:8080 can be accessed in both WSL and Windows via 127.0.0.1:8080 url
My issue is that the ports specified as :::3006 can be accessed via 127.0.0.1:3006 only inside WSL, but from Windows, it works only via the network URL like http://172.28.100.200:3006.
When I send the request to 127.0.0.1:3006 from Windows, there is no connection error, but the server inside WSL does not receive it while using the network address, it does.
How can I investigate this and make the Windows port at 127.0.0.1:3006 forward requests into the same port in WSL?
UPDATE:
So I solved this by adding a port proxy, but again, WSL network IP is needed for this to work:
Any chance to avoid using network IP?

Remote Desktop Connection with Ngrok

I want connect to my other computer with remote desktop connection but i need a problem.
I did setup ngrok and launched it and tried connect it but it doesn't connect.
This is what i did:
Setup and launched ngrok as:
ngrok tcp 5555
and i switched my own laptop and launched remote desktop connection and did that:
But it doesn't connect :(
Note: I allowed Remote Desktop Connection in control panel.
Did i miss something or how to do it correctly?
You have wrong port number for your remote desktop connection. You have to use default RDP port 3389.
Setup and launched ngrok as:
ngrok tcp 3389

SSH Tunnel to Ngrok and Initiate RDP

I am trying to access my Linux machine from anywhere in the world. I have tried originally port forwarding and then ssh'ing in; however, I believe my school's WiFi won't allow port forwarding (every time I ran it, it would tell me connection refused). I have setup an account with ngrok and I can remotely SSH in, but now I am wondering if it is possible to RDP. I tried connecting via the Microsoft Remote Desktop app on Mac, but it instantly crashes. I have also looked at trying to connect with localhost, but it's not working. So far, I have tried (with xxxx being the port):
ssh -L xxxx:localhost:xxxx 0.tcp.ngrok.io
and
ssh -L xxxx:localhost:xxxx <user>#0.tcp.ngrok.io
but my computer won't allow it and after about 2 or 3 times, it warns me of a possible DNS Spoofing. Is there anyway that I can run a remote desktop of my linux machine that I have ssh tunneled to (from my mac) on ngrok? Thank you!
First you'll need to sign up with ngrok if you haven't already and you'll be given an authtoken. You'll need to install this by running
./ngrok authtoken <insert your token here>
This will save your token to a file located ../username/.ngrok/ngrok.yml
Then you'll need to ask ngrok to create a TCP tunnel from their servers to your local machine's Remote Desktop port which should be 3389 by default
ngrok tcp 3389
Give it 30 seconds or so then jump to http://localhost:4040/status to see what the tcp address ngrok has allocated you. It should look something like tcp://1.tcp.ngrok.io:158764
Now you should be able to remote into your machine using address 1.tcp.ngrok.io:158764

telnet to azure vm port from outside

I want to telnet virtual machine on port 1234. I have server.exe running on vm which listens to port 1234.
When I run telnet within virtual machine cmd "telnet 127.0.0.1 1234" response is
"ok"
However when I run telnet from outside using "telnet publicIP 1234" response is
Connecting To publicIP...Could not open connection to the host, on
port 1234: Connect failed
I have added endpoints in azure portal and tried switching off the firewall from both virtual machine and my local machine.
Can anyone please suggest?
Two things to consider:
Make sure that your server.exe listens also the VM network adapter, but not only on 127.0.0.1
Make sure that your ISP( Internet Provider) does not block outgoing ports - very common issue.
To avoid (2) change the public port for the VM Endpoint to 80 and try with telnet publicIP 80
To make sure you comply with (1), while on the VM try telnet **localIP** 1234

offering mysql on localhost via a ssh layer

I have 2 machines: One has a mysql server that runs on localhost.The second one has no mysql server. I want to access the mysql server from the first machine on the second machine also on localhost. It should be something like a virtual localhost.
The first machine should log in the second machine via secure socket and should emulate the server there somehow.
Is something like this possible, how is it called , and how does it work.
Is this what is called a tunnel?
Yes, this is what is called a tunnel.
Assuming host A is running the mysql server and host B is the one that dose not.
To create the tunnel enter the following on host B:
ssh -L 3306:localhost:3306 username#A
(Add -f -N to the command to not execute any command on the remote host and immediately background the ssh connection).
This creates a listening port 3306 on host B which is forwarded over the ssh tunnel to localhost:3306 on host A.
Now just run mysql on host B and you should be able to connect to the mysql server on host A.
Hope it helps!

Resources