Skip to content

vanrand/ssh-port-forwarding-ref

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

ssh-port-forwarding-ref

Quick reference of ssh port forward commands -- because I can never seem to remember...

Network diagram:

  near-host   <--->   this-box   <--->   remote-box   <--->   far-host
  (4.3.2.1)           (1.2.3.4)          (5.6.7.9)            (9.8.7.6)
Make service running at remote-box:3000 available at this-box:3001
# All equivelent:
ssh -L 1.2.3.4:3001:5.6.7.9:3000 user@remote-box -N
ssh -L this-box:3001:remote-box:3000 user@remote-box -N
Make service running at far-host:80 available at this-box:5000
ssh -L this-box:5000:far-host:80 user@remote-box -N
Make service running at near-host:443 available at remote-box:4000
ssh -R remote-box:4000:near-host:443 user@remote-box -N

Ports within the same host:

Make service running at this-box:3000 available at this-box:3005
# All equivelent:
ssh -L this-box:3005:this-box:3000 user@this-box -N
ssh -L 1.2.3.4:3005:1.2.3.4:3000 user@localhost -N
Make service running at remote-box:5000 available at remote-box:5010
# All equivelent:
ssh -R remote-box:5010:remote-box:5000 user@remote-box -N
ssh -R 5.6.7.9:5010:5.6.7.9:5000 [email protected] -N

Multiple ports and wildcard address

Make both ports 443 & 902 on far-host available on all IPs on this-box:
ssh \
 -L *:443:far-host:443 \
 -L *:902:far-host:902 \
user@remote-box -N
Make port 22 on this-box available at port 8022 on remote-box:
ssh -R *:8022:*:22 user@remote-box -N

About

Quick reference of ssh port forward commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published