加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

unix – 在SSH Config Hostname中仅使用模式的一部分

发布时间:2020-12-16 01:11:28 所属栏目:安全 来源:网络整理
导读:我有一个类似下面的SSH配置,适用于: ssh b21ssh 23ssh s267 示例.ssh / config(传递的主机名在%h处插入): host s* HostName atrcu%h.example.com User example Port 22host b* HostName atrcx%h.example.com User example Port 22host ??* HostName atvts
我有一个类似下面的SSH配置,适用于:
ssh b21
ssh 23
ssh s267

示例.ssh / config(传递的主机名在%h处插入):

host s*
    HostName atrcu%h.example.com
    User example
    Port 22
host b*
    HostName atrcx%h.example.com
    User example
    Port 22
host ??*
    HostName atvts%h.example.com
    User example
    Port 2205

但我想在主机中包含用户名:

ssh b21ex

这将ssh:

example@atvts21.example.com

但相反会:

atvts21ex.example.com

他们是否有任何方式来切换/修改%h,因为它已经通过,并且可能连接匹配更多模式以获得用户名?

我认为你必须为每个可能的缩写匹配创建单独的HostName / User条目.然后,您可以使用%r访问每个用户的单独标识文件.这将允许您跳过使用user @ host进行登录,但代价是创建更复杂的配置文件.

你可能会更好地写一个脚本或shell别名来解开你的缩写并将它们交给ssh准备好了.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读