大网数据广告活动
服务器运维问答

Use of alias in /etc/hosts or ssh_config

· 52CE 我爱测

I'm have configured a bastion or (jump) box to access a virtual private network. #ssh_config Host bastion HostName 14.90.140.120 User me IdentityFile ~/.ssh/me ForwardAgent yes Host 10.1.* User me IdentityFile ~/.ssh/me ProxyComm…

问题原文

原帖链接 · bearrito · CC BY-SA 3.0

I'm have configured a bastion or (jump) box to access a virtual private network.

#ssh_config
Host bastion
HostName 14.90.140.120
User me
IdentityFile ~/.ssh/me
ForwardAgent yes

Host 10.1.*
User me
IdentityFile ~/.ssh/me
ProxyCommand ssh bastion -W %h:%p

I am able to ssh into both the bastion and 10.1.1.6 address with no issues.

What I would like to be to do is add an entry like the following. Note: I have not time for DNS at the moment, but it would be my preferred approach.

#/etc/hosts
10.1.1.6    my-host-inside-vpc.corp.internal

When I do that however and try to access the machine I get the following

➜  ~ ssh -vvv my-host-inside-vpc.corp.internal
     debug1: Reading configuration data /home/me/.ssh/config
     debug1: /etc/ssh/ssh_config line 19: Applying options for *
     debug2: ssh_connect: needpriv 0
     debug1: Connecting to my-host-inside-vpc.corp.internal [10.1.1.6] port 22.

At this point the operation times out.

已采纳解答

原帖链接 · Zoredache · CC BY-SA 3.0

The Host matches the name you use when you connect, not the ip after dns resolution.

Try using Host *corp.internal instead.

Per our discussion in the comments if you want to use the symbolic names, yet are required to resolve them to IPs for the bastion host, then you could use a sub-expressionist in the ProxyCommand like this.

ProxyCommand ssh bastion -W $(getent hosts $h | cut -d " " -f1):%p

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-09-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。