远程端口转发| SSH
当我进行远程端口转发时,我遇到了一个小问题。
我试图建立以下连接:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过创建/编辑〜/.ssh/config File为SSH连接分配一个别名。创建文件时,您可以定义类似的连接:
然后您可以使用:
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:
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.