# git通过SSH Tunnel代理访问

正如 [SSH端口转发](https://github.com/huataihuang/cloud-atlas-draft/tree/6f3204fffc11cf006abd394631e2598d98b415c3/service/ssh/ssh_port_forwarding/README.md) 的应用场景 "ssh动态端口转发" :有时候我们不得不通过SOCKS代理方式来访问目标服务器。既然SSH Tunnel能够实现动态端口转发，也就是说git ssh也能够通过这个方式访问代码仓库。

配置方法是修改 `~/.ssh/config` 设置（测试成功）：

```
Host gitlab.example.com
  User huatai
  ProxyCommand nc -x localhost:2280 %h %p
```

或者使用(未测试成功)

```
Host gitlab.example.com
  User huatai
  ProxyCommand ssh -q localhost:2280 nc %h %p
```

> 注意，需要在本地安装一个 `nc` 工具（即OpeBSD版本的netcat)，然后就可以直接进行git仓库同步了。


---

# 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://huataihuang.gitbook.io/cloud-atlas-draft/devops/git/git_ssh_tunnel_proxy.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.
