1
0
Files
cheatsheet-site/content/ssh/port-forwarding.md
yuudi 728a3db957
Some checks failed
Build / build (push) Has been cancelled
init
2025-08-12 18:37:54 -06:00

25 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

+++
date = '2025-08-10T11:55:59Z'
title = 'Port Forwarding'
+++
- `-L` 本地转发(本地访问远程)
- `-R` 远程转发远程访问本地如clash
```pseudo-shell
ssh -R <remote_listen_port>:<local_host>:<local_port> <user>@<ssh_server>
ssh -L [<local_listen_host>]:<local_listen_port>:<remote_host>:<remote_port> <user>@<ssh_server>
```
<shell-commands-builder-component
command="ssh -R ${REMOTE_LISTEN_PORT}:${LOCAL_HOST:-localhost}:${LOCAL_PORT} ${SSH_HOST} ${COMMAND}"
variables='[{"name":"REMOTE_LISTEN_PORT","default":"7890"},{"name":"LOCAL_HOST","default":"localhost"},{"name":"LOCAL_PORT","default":"7890"},{"name":"SSH_HOST","required":true},{"name":"COMMAND","default":"sleep infinity"}]'>
</shell-commands-builder-component>
---
<shell-commands-builder-component
command="ssh -L ${LOCAL_LISTEN_PORT}:${REMOTE_HOST:-localhost}:${REMOTE_PORT} ${SSH_HOST} ${COMMAND}"
variables='[{"name":"LOCAL_LISTEN_PORT","default":"8080"},{"name":"REMOTE_HOST","default":"localhost"},{"name":"REMOTE_PORT","default":"80"},{"name":"SSH_HOST","required":true},{"name":"COMMAND","default":"sleep infinity"}]'>
</shell-commands-builder-component>