0

These days in Iran, the Global internet is blocked. just we access the internal internet.

So I have to connect to a server in Iran (Ubuntu 20), Then connect to the second server in another country. (VMESS Method)

In the Iran server, I use this command to connect to the second server via Putty

ssh -o GatewayPorts=true -L 80:0.0.0.0:80 root@188.165.117.138

It works and I can connect my client's VPN software to the Iran server. So I can access the internet.

But if I close the Putty, the connection will be lost.

How can I make this connection permanent? How to connect with the second server even after closing putty?

user2726957
  • 31
  • 1
  • 1
  • 6

1 Answers1

1

You need to keep the SSH connection alive for the tunnel to exist, so if you don't want to run the full PuTTY GUI then you should look at the plink command. It comes from the same developer as PuTTY but is all shell based. (Alternative Binaries section here https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)

You should also look at using a the Jump server (also known as a Bastion) and the proxy command option (See this question and answer How do I use putty (and/or plink) command line to forward through 2 intermediate hosts to a database?) so you can set it up to run the ssh command automatically.

e.g.

plink -A -proxycmd  "ssh -o GatewayPorts=true -L 80:0.0.0.0:80 root@188.165.117.138"  user@ubuntu

Assuming you also have port forwarding configured in PuTTY then you should add that as a -L option to the above command

hardillb
  • 1,552
  • 2
  • 12
  • 23