ๆไนๅ็ ~/.ssh/config ไธญ็้
็ฝฎๆฏ
Host *
<directives>
User root
Include hosts-enabled/*.config
hosts-enabled/gcp.config
Host gcp-1
HostName 35.194.164.130
User hi
ๅฝๆ่ฏๅพ ssh gcp-1 ๆถ๏ผๅ็ฐๆปๆฏไปฅ root ็จๆท่้ hi ็จๆท็ป้๏ผ้ค้่ขซ่ฟๆฎต้
็ฝฎๆชๅฐไธป้
็ฝฎๆไปถ Host *
ไธๆน
ๅๅ ๆฏ Include directive may appear inside a Match or Host block to perform conditional inclusion. I had my Include statement trailing a Host directive so it was being included into that Host's config. ssh does not honor indention level as I supposed
ๅฆๆๆๅฐ
Host *
<directives>
User root
ไฝไธบ default.config ๅญ้
็ฝฎๆไปถๆพๅจ hosts-enabled ็ฎๅฝไธญ๏ผไธป้
็ฝฎๆไปถๅชไฟ็Include hosts-enabled/*.config
, gcp.config ไธญ็ User hi
ๆไปคไป็ถไธไผ็ๆ๏ผๆ default.config ไธญ็ User root
ๆไปคๅ ้คๅฐฑๆญฃๅธธไบ๏ผๆ นๆฎ man page
For each parameter, the first obtained value will be used. The configuration files contain sections separated by Host specifications, and that section is only applied for hosts that match one of the patterns given in the specification. The matched host name is usually the one given on the command line (see the CanonicalizeHostname option for exceptions).
Since the first obtained value for each parameter is used, more host-specific declarations should be given near the beginning of the file, and general defaults at the end.
ๆ นๆฎๅญๆฏ้กบๅบ๏ผdefault.config ไธญ็้ ็ฝฎไผๆฏ gcp.config ไธญ็้ ็ฝฎๅ ๅ ่ฝฝ
ๅฝๆๆ Include ๆไปคๆพๅจไธไธช ๅธฆๆ HostName ็ host block ไนๅๆถ๏ผ่ฏๅพ็ป้ไธๅฐไธปๆบ็่ณไผๆฅ้
ssh: Could not resolve hostname gcp-1: Temporary failure in name resolution
่ฟๆฏๅ ไธบๅ้ข็ HostName ๆไปค่ฆ็ไบๅ้ขๆๆ็ HostName ๆไปค
ๆไปฅ Include ๆไปคๆๅฅฝๅ
ๅซๅจๆๆ Host ๆไปคไนๅ๏ผๆ่
You can leave the Include statement at the end of the file if you precede it with Match all. This terminates the previous Host/Match, and then conditionally always includes the file(s). So, the file would end with:
Match all
Include config.d/*
Top comments (0)