在我的~/.ssh/config
我想定义这样的东西
# myvm.hosting.com is a real existing domain
Host myvm.hosting.com
# tunnel to mysql
LocalForward 3311 localhost:3306
# example.com is a real existing domain
Host example.com
User myuser
HostName myvm.hosting.com
# example.org is a real existing domain
Host example.org
User myuser
HostName myvm.hosting.com
当我运行时,ssh example.com
我想执行为其定义的端口转发myvm.hosting.com
,但它看起来HostName
并没有被覆盖Host
......
如何实现这个目标?
附言:
Host *
不是一个选择,因为我有很多“基础机器”喜欢myvm.hosting.com
- 我想继续使用真实 DNS,我不想使用昵称
谢谢!
答案1
第一个设置host
应用于所有连接
LocalForward 3311 localhost:3306
# myvm.hosting.com is a real existing domain
Host myvm.hosting.com
# tunnel to mysql
# example.com is a real existing domain
Host example.com
User myuser
HostName myvm.hosting.com
# example.org is a real existing domain
Host example.org
User myuser
HostName myvm.hosting.com