小编and*_*rux的帖子

如何将本地转发设置添加到我的 ssh 配置文件中?

我目前可以这样做:

ssh 12.34.56.78 -L 8888:localhost:8000

然后我可以打开本地浏览器到 localhost:8888 并查看该应用程序在我的服务器中运行,地址为 12.34.56.78:8000。

我想避免输入该转发命令,而是将该配置放在我的 ssh 配置文件中。

目前我有这个:

Host myhost
    User myuser
    Hostname 12.34.56.78
    IdentityFile ~/.ssh/id_rsa
    LocalForward 8888 12.34.56.78:8000
Run Code Online (Sandbox Code Playgroud)

我认为它会工作相同,但是当我myhost像平常一样 ssh 进入,然后尝试打开浏览器到 localhost:8888 时,我无法再看到该应用程序正在运行,并且我在 myhost 控制台中收到以下消息:

channel 4: open failed: connect failed: Connection refused
channel 3: open failed: connect failed: Connection refused
channel 3: open failed: connect failed: Connection refused
channel 4: open failed: connect failed: Connection refused
channel 3: open failed: connect failed: Connection refused
Run Code Online (Sandbox Code Playgroud)

我想我可以添加一个别名来运行 ssh 命令并完成它,但我希望在我的配置文件中正确设置这个,并且,如果能够看到我的应用程序在浏览器中运行而无需 ssh进入我的主机可以实现可能是一个巨大的优势。

任何人都可以帮忙解决这个问题吗?

port-forwarding ssh-tunnel localhost

22
推荐指数
2
解决办法
7万
查看次数

标签 统计

localhost ×1

port-forwarding ×1

ssh-tunnel ×1