远程端口转发| SSH

发布于 2025-01-31 22:15:27 字数 345 浏览 4 评论 0原文

当我进行远程端口转发时,我遇到了一个小问题。

我试图建立以下连接:

ssh -L 8000:127.0.0.1:8000 user@server

当前有效,我没有任何问题python manage.py runserver

但是,当我退出时,我想重新建立连接以命令runserver我必须运行相同的命令。

因此,我想知道是否有一种使用ssh user@server访问的方法,并且仍然可以在不执行完整命令的情况下使用某些端口。

额外的笔记:我正在运行Windows

I've encountered a minor issue when I am doing remote port forwarding.

I am trying to establish connection like the following:

ssh -L 8000:127.0.0.1:8000 user@server

This currently works and I have no issues doing python manage.py runserver.

However when I exit and I want to re-establish the connection in order to command runserver I will have to run the same command.

I am therefore wondering if there is a way to access with ssh user@server and still be able to use certain ports without doing the full command.

Extra notes: I am running windows

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

厌味 2025-02-07 22:15:27

您可以通过创建/编辑〜/.ssh/config File为SSH连接分配一个别名。创建文件时,您可以定义类似的连接:

Host dev
    HostName dev.example.com
    User john
    Port 2322

然后您可以使用:ssh dev

请参阅: https://linuxize.com/post/using-sh-config-file/

我没有专门测试端口转发,但是如果您查看ssh_config的男人页面,似乎有端口转发选项可以在配置文件中配置:

https://man.openbsd.org/openbsd-current/man5/ssh_config.5

我使用〜/.ssh/config以使用python和Windows ssh client的git配置ssh别名但是,在Windows上,这可能取决于您如何配置SSH客户端。

You can assign an alias for an ssh connection by creating/editing ~/.ssh/config file. When you create the file, you can define a connection something like:

Host dev
    HostName dev.example.com
    User john
    Port 2322

then subsequently you can use: ssh dev

See: https://linuxize.com/post/using-the-ssh-config-file/

I haven't specifically tested port forwarding, but if you look at the man page for ssh_config, there appear to be port forwarding options which can be configured in the config file:

https://man.openbsd.org/OpenBSD-current/man5/ssh_config.5

I use ~/.ssh/config to configure ssh aliases using python and the Git for Windows SSH client on Windows, however, it may depend on how you have configured your ssh client.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文