使用SSH构建内网隧道

之前一直使用学校提供的vpn工具访问放在学校机房内网的服务器,多数时间是没有问题的,但到重大事件时会提高安全防范级别,这是vpn服务器就会关停,在家里工作就傻眼了。于是就想看看是否有什么工具可以穿透内网,保证我有需要的时候可以随时访问。

搜索了一圈后,发现ssh就能实现这个功能。前提是需要有一个可以访问的外网服务器。

假定,内网服务器为N,外网服务器为W。

  1. 在N服务器上可以使用密钥登陆服务器W,这样可以保证登陆时不需要使用密码。
  2. 在服务器N上安装autossh工具,其主要功能是提高ssh链接稳定性,并在ssh连接断开后自动重连。
  3. 在服务器N上执行:
sudo autossh -M 7291 -gCNR 7290:localhost:22 -i ~/.ssh/id_rsa user@W &

这样就可以通过服务器W的7290端口访问服务器N的22端口:

ssh -p 7290 user@W

当然,用同样方法还可以构建其他应用,比如80端口等。

参考:https://blog.csdn.net/upshi/article/details/78630285


已发布

分类

来自

标签:

评论

《 “使用SSH构建内网隧道” 》 有 14 条评论

  1. wlx 的头像
    wlx

    外网服务器的sshd配置文件需要修改:
    GatewayPorts yes

  2. sera ou kamagra apparaître dans un test de drogue

    comprar kamagra en espana

  3. ordering enclomiphene overnight no rx

    buy enclomiphene australia over the counter

  4. androxal order online with e check

    how to order androxal online mastercard accepted

  5. how to order flexeril cyclobenzaprine uk buy cheap

    order flexeril cyclobenzaprine usa seller

  6. where do i get dutasteride

    how to get free dutasteride samples

  7. ordering gabapentin generic in canada

    how to buy gabapentin buy online usa

  8. get fildena generic online mastercard

    purchase fildena generic pricing

  9. ordering itraconazole buy hong kong

    order itraconazole us pharmacies

  10. US pharmacies for avodart without rx

    purchase avodart buy virginia

  11. buy cheap staxyn without a rx

    cheapest buy staxyn generic south africa

  12. buying rifaximin buy dublin

    order rifaximin cheap real

  13. get xifaxan buy mastercard

    discount xifaxan generic pharmacy usa

  14. nad pナ册pテ。ナセkou nahrazuje 099144

    kamagra recepty

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注