# SSH-port-forwarding

```bash
# 本地转发（SERVER可以访问目标服务）本机监听forwardingPort
ssh -g -f -N -L forwardingPort:targetIP:targetPort user@SERVER
# 远程转发（SERVER具有公网IP,提供内网服务外网访问）SERVER监听forwardingPort
ssh -f -N -R forwardingPort:targetIP:targetPort user@SERVER
# 动态转发（创建了SOCKS代理服务，流量转发至SERVER）
ssh -p PORT -f -N -D *:20080 user@SERVER
```

## Reference

1. [IBM](https://www.ibm.com/developerworks/cn/linux/l-cn-sshforward/index.html)
2. [SSH Manual Page](https://man.openbsd.org/ssh)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.junyangz.com/ops/ssh-port-forwarding.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
