Skip to content

Instantly share code, notes, and snippets.

@trydofor
Created September 26, 2017 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trydofor/831b9665dfcd173b3e0f69265d3111cd to your computer and use it in GitHub Desktop.
Save trydofor/831b9665dfcd173b3e0f69265d3111cd to your computer and use it in GitHub Desktop.
ssh隧道,做代理或转发
#ssh隧道有3种类型:
#动态端口转发(Socks 代理)-D
ssh -D 9090 ssh-host
产生一个本地sock5代理,端口是9090
#本地端口转发(正向代理)-L
ssh -L 3306:mysql-server:3306 ssh-host
开启本地3306端口监听,等于访问mysql-server的3306端口
#远端端口转发(反向代理)-R
ssh -R 8080:local-jetty:8080 ssh-host
开启远程8080端口监听,等于访问本地 local-jetty的8080端口
#常用参数
-f ssh将在后台运行
-N 不执行命令,仅转发端口
-C 压缩传送的数据
-i 使用指定的密钥登录
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment