Linux SSH 端口转发在 ~/.ssh/config 文件中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9146457/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SSH Port forwarding in a ~/.ssh/config file?
提问by Snow_Mac
So I typically run this command a lot:
所以我通常会经常运行这个命令:
ssh -L 5901:[email protected]:5901
ssh -L 5901:[email protected]:5901
I use it to do VNC over SSH.
我用它通过 SSH 进行 VNC。
How do I convert that command into something that will work in a ~/.ssh/config file?
如何将该命令转换为可以在 ~/.ssh/config 文件中使用的命令?
ex:
前任:
host yam
HostName yam.myHost.edu
User myUserName
all I want to do is type:
我想要做的就是输入:
ssh yam
And have it open a SSH shell with a local listen port, and a remote port forwarded to it.
并让它打开一个带有本地侦听端口的 SSH shell,并将远程端口转发给它。
Suggestions?
建议?
采纳答案by Johnsyweb
You can use the LocalForward
directive in your host yam
section of ~/.ssh/config
:
您可以LocalForward
在您的host yam
部分使用该指令~/.ssh/config
:
LocalForward 5901 computer.myHost.edu:5901