7

使用ssh隧道代理并连接任意服务

 3 years ago
source link: https://shingle.me/post/%E4%BD%BF%E7%94%A8ssh%E9%9A%A7%E9%81%93%E4%BB%A3%E7%90%86%E5%B9%B6%E8%BF%9E%E6%8E%A5%E4%BB%BB%E6%84%8F%E6%9C%8D%E5%8A%A1/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

使用ssh隧道代理并连接任意服务

2019-09-20 14:50:05 约 210 字 预计阅读 1 分钟 243 次阅读

connect to ssh tunnel server

直接连接 ssh 服务器

ssh [email protected]

-p 指定端口
-i 指定私钥

使用 socket5 代理连接 ssh 服务器

ssh -o ProxyCommand='nc -x 127.0.0.1:1086 %h %p' [email protected]

#127.0.0.1:1086 是你的socket5代理地址

使用 ssh 隧道(ssh tunnel)访问服务器的内网服务

比如在本机访问内网 redis

ssh -L 8888:172.0.0.1:6379 [email protected]

-f 在后台连接,不阻塞命令
-N 打开隧道时不带shell界面
#172.0.0.1:6379 是服务器上的内网地址
#本机就可以通过8888端口连接该服务

使用 ssh内网穿透

ssh -f -N -R xx.xx.xx.xx:8080:localhost:8080 [email protected]
#localhost:8080 是本机的服务地址
# xx.xx.xx.xx:8080 是服务器ip和对应的端口

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK