I am LAZY bones?
AN ancient AND boring SITE

ssh反向连接

先介绍一下我这里的情况: 公司的电脑是在内部网里面,不可能有公网地址;家里的电脑是adsl拨号,有动态的公网IP,动态绑定到域名 xxx.xxx.org
如果现在想从家里ssh到公司的电脑,直接连接肯定是不行的,不过可以用以下方法:
1. 在公司电脑上执行: ssh -f -N -R 12121:localhost:22 xxx@xxx.xxx.org
2. 然后在家里的电脑上执行: ssh xxxx@localhost -p 12121 就可以成功连上公司的电脑了.

上面命令里面的 12121 是任一个本地端口(上面例子里面是家里电脑的端口),可以在合理的范围内任意指定.我的理解是这样的: 前一个命令相当于把公司机器的22端口(localhost:22) 映射到 家里机器的12121端口. 然后在家里电脑上直接ssh 本机的 12121 端口,数据就会被转发到公司机器了.就这么简单.

参考此文和 man ssh

最后修改时间: 2008年01月24日 13:30

本文章发表于: 2008年01月24日 13:30 | 所属分类:CLI软件, 经验技巧. | 您可以在此订阅本文章的所有评论. | 您也可以发表评论, 或从您的网站trackback.

3 个评论 关于: “ssh反向连接”

  1. 9linux 在 2008年05月24日 10:42 说:回复

    我的妈呀,实践过没有?太牛了

  2. bones7456 在 2008年05月24日 15:38 说:回复

    呵呵,当然是实践过了才发上来的啊。

  3. Russo 在 2025年06月17日 06:43 说:回复

    Dear Founder,

    An active investor we represent is now reviewing investment ready business ideas across all sectors no matter your industry or stage. What matters most is a compelling, scalable idea with strong execution potential.

    Available Funding Options:
    • 3% annual interest rate
    • No early repayment penalties
    • Convertible loan option available – convert to 10–15% equity after 2 years (optional)

    Whether you’re building the next big tech platform, expanding a niche brand, or launching a bold new venture, now’s your chance to access smart capital on founder-friendly terms.

    Simply send in your pitch deck or business plan to start the conversation. If your idea is solid, we’re ready to move.

    Let’s help you bring your vision to life.

    Yours Truly,
    Chary Marshal
    Investment Consultant/Strategist
    Email: charyl74@akirapowered.com

发表评论