Jacky's blog
首页
  • 学习笔记

    • web
    • android
    • iOS
    • vue
  • 分类
  • 标签
  • 归档
收藏
  • tool
  • algo
  • python
  • java
  • server
  • growth
  • frida
  • blog
  • SP
  • more
GitHub (opens new window)

Jack Yang

编程; 随笔
首页
  • 学习笔记

    • web
    • android
    • iOS
    • vue
  • 分类
  • 标签
  • 归档
收藏
  • tool
  • algo
  • python
  • java
  • server
  • growth
  • frida
  • blog
  • SP
  • more
GitHub (opens new window)
  • 服务器tutorial
  • spring

  • 数据库

  • 运维

    • SSH 进行本地文件的交互
    • SSH Tunnel结合本地代理案例
      • 操作步骤
      • issue
        • 远程服务器拒绝了连接
    • 查询本地电脑外网 IP
    • dns查询
    • 内网穿透
  • other

  • 《server》
  • 运维
Jacky
2024-09-21
目录

SSH Tunnel结合本地代理案例

通过本地电脑作为代理给远程服务器访问

可以通过本地电脑作为代理,帮助远程服务器访问外网。常见的方法是使用 SSH 隧道(SSH Tunnel)结合本地代理来实现。以下是一个实现思路:

# 操作步骤

以 7890 作为端口转发为例子

  1. ssh -R 7890:localhost:7890 ubuntu@<hostname/ip>: 将远程服务器(<hostname/ip>)的 7890 端口,通过 SSH 隧道映射到本地机器的 7890 端口。这样,远程服务器上的任何发往端口 7890 的流量都会通过 SSH 隧道被转发到你本地机器的端口 7890
  • -R 7890:localhost:7890: This is the option to set up a reverse tunnel. It tells SSH to forward the port on the remote server back to the local machine.
    • -R: The reverse tunnel option. It forwards a port from the remote server back to the local machine.
    • 7890:localhost:7890: This means:
      • Forward traffic from port 7890 on the remote server (<hostname/ip>).
      • To localhost:7890 on the local machine (i.e., localhost is the machine from which you're initiating the SSH connection).
  1. 在 remote 端,使网络走端口 7890: export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
至此,remote端走7890的端口请求都会被转发到本地的7890端口, 而本地7890端口就是VPN服务端口,从而实现网络翻墙

# issue

# 远程服务器拒绝了连接

ssh -R 7890:localhost:7890 ubuntu@VM-4-9-ubuntu
kex_exchange_identification: Connection closed by remote host
Connection closed by 127.0.0.1 port 7890
1
2
3
上次更新: 2024/12/01, 17:09:08
SSH 进行本地文件的交互
查询本地电脑外网 IP

← SSH 进行本地文件的交互 查询本地电脑外网 IP→

最近更新
01
npx 使用指南
10-12
02
cursor
09-28
03
inspect
07-20
更多文章>
Theme by Vdoing | Copyright © 2019-2025 Jacky | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式