Skip to content

Instantly share code, notes, and snippets.

@rolldone
Last active September 16, 2022 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolldone/12036ac19d5bddfb015f1cdde90b443e to your computer and use it in GitHub Desktop.
Save rolldone/12036ac19d5bddfb015f1cdde90b443e to your computer and use it in GitHub Desktop.
SSH Jump old version technique

This is best for publish local project to internet use own public server. For example i have localhost port 80 on my local and planning publish it.

First create your port forwading first and connect to own public server.

ssh -L [new_port_forward]:[new_host_forward]:[ip_host_remote_port] root@localhost -p 2200
or you can use -T without tty terminal
ssh -T -L [new_port_forward]:[new_host_forward]:[ip_host_remote_port] root@localhost -p 2200

Next open new terminal again on your local

ssh root@localhost -p [new_port_forward]

Then open browser access url http://[new_host_forward]:[port_forward]

Create SSH Jump Connection use Embedded Forward Technique

Create Config File on ~/.ssh/config

Host wsl_root
  HostName localhost
  User root
  Port 2200
  IdentityFile C:\Users\donny\.ssh\id_rsa
  ProxyCommand ssh -v rollproject -W [%h or localhost]:[%p or rollproject_port]

Host rollproject
  HostName 192.168.1.1
  User root
  Port 22

Then start connecting

ssh -v wsl_root
Explanation :
  • -v -> is Verbose
  • wsl_root -> is host from config file

You can use with raw technique :

ssh -o ProxyCommand="ssh -v root@[target_server_host] -W [%h or localhost]:[target_server_port]" root@localhost -p 2200 

Real example :

Method 1 :
ssh -o ProxyCommand="ssh root@103.157.97.69 -W %h:22" root@localhost -p 2200

If not working use method 2: 
ssh -o ProxyCommand="ssh root@103.157.97.69 -W localhost:22" root@localhost -p 2200

Create SSH Jump Connection use NetCat

Create Config File on ~/.ssh/config

Host wsl_root
  HostName localhost
  User root
  Port 2200
  IdentityFile C:\Users\donny\.ssh\id_rsa
  ProxyCommand ssh -v rollproject nc [%h or localhost] [rollproject_port]

Host rollproject
  HostName 192.168.1.1
  User root
  Port 22
  ForwardAgent no

Then start connecting

ssh -v wsl_root
Explanation :
  • -v -> is Verbose
  • wsl_root -> is host from config file

You can use with raw technique :

ssh -o ProxyCommand="ssh -v root@[target_server_host] nc [%h or localhost] [target_server_port]" root@localhost -p 2200 

Real example :

Method 1 :
ssh -o ProxyCommand="ssh root@103.157.97.69 nc %h 22" root@localhost -p 2200

If not working use method 2: 
ssh -o ProxyCommand="ssh root@103.157.97.69 nc localhost 22" root@localhost -p 2200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment