lof*_*ops 5 ssh networking port-forwarding
我有一个只公开 SSH 的远程服务器。它有在其他端口上运行的服务,例如端口 3306 上的数据库。这些端口不能远程访问,但可以从服务器上下文 ( localhost:3306) 中访问。
使用ssh -LI 可以访问远程服务器上的单个端口。但是如何通过 ssh/sshuttle 连接让我的本地机器可以访问所有这些端口?
在远程服务器上定义一个指向自身的辅助 IP 地址,例如 10.0.0.1。(与 127.0.0.1 相同。)
在您的本地机器上,创建您的 sshuttle 连接,如下所示:
sshuttle -r user@remote 10.0.0.1
# "user" is your username on the remote machine
# "remote" is the name or IP address of the remote machine
Run Code Online (Sandbox Code Playgroud)
您现在可以访问位于 10.0.0.1 地址的远程服务器。因为它将来自 10.0.0.1 的连接理解为“自身”,所以所有端口都可以在该地址访问。(一旦您关闭 sshuttle 连接,它们就会停止访问。)
您可以使用以下命令确认这一点:
nmap remote # returns only ssh port
nmap 10.0.0.1 # returns all ports
Run Code Online (Sandbox Code Playgroud)
您现在可以使用地址连接到您的数据库10.0.0.1:3306。例如,如果它是一个 MySQL 数据库,您可以使用 MySQL Workbench 连接到它。
如果这种方法适合您,您可能需要研究使用sshoot来管理您的 sshuttle 连接。
| 归档时间: |
|
| 查看次数: |
1387 次 |
| 最近记录: |