5,337
edits
Line 95: | Line 95: | ||
===Port Forwarding=== | ===Port Forwarding=== | ||
Also: SSH Tunneling, SSH Proxy, SSH Reverse Proxy | Also known as: SSH Tunneling, SSH Proxy, SSH Reverse Proxy | ||
If you need to access a port on the remote computer, you can use the <code>-L</code> option to forward ports from the remote to the local machine. | |||
If you need to access a port on the remote computer, you can use the <code>-L</code> option to forward ports from the remote to the local machine. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ssh -L <localport>:localhost:<remoteport> <remoteurl> | ssh -L <localport>:localhost:<remoteport> <remoteurl> | ||
# E.g. ssh -L 8080:localhost:80 [email protected] | # E.g. ssh -L 8080:localhost:80 [email protected] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
You can also do the reverse, giving the remote access to a local port using <code>-R</code> | You can also do the reverse, giving the remote access to a local port using <code>-R</code> | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 106: | Line 108: | ||
# E.g. ssh -R 8080:localhost:80 [email protected] | # E.g. ssh -R 8080:localhost:80 [email protected] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
;Notes | |||
* You can also run this without creating a shell using <code>-N</code> See [https://unix.stackexchange.com/questions/100859/ssh-tunnel-without-shell-on-ssh-server SE Answer]. | |||
* Adding <code>-f</code> pushes ssh to the background. | |||
** This will implicitly add <code>-n</code> which redirects <code>stdin</code> from <code>/dev/null</code>. | |||
===alias=== | ===alias=== |