ssh config: I have many hosts who I want to use settings from 2 different wildcard hosts respective, please review my attempt

I have 2 sets of hosts who I want to use settings from 2 seperate wildcard hosts.

I also have a huge number of hosts so need help on which style is best for this scenario. The hosts are mostly in the format of x1 x2 x3...

My attempts:

1:

host one
  user cat

host two
  hostname 2

host three
  hostname 3

host one two three
  user apple
  identityFile ~/.ssh/id_rsa

host x1
  hostname 7

host y2
  hostname 8

host z3
  hostname 9

host x1 y2 z3
  user duck
  identityFile ~/.ssh/quack

Omitting the hosts only using the wild card hosts but they apply to the hosts.

2:

 host x* y* z*
  user duck
  identityFile ~/.ssh/

# for hosts one two three

host * 
  user apple
  IdentityFile ~/.ssh/quack

Are these methods correct and Any suggestions for a better methods?

Please critique.

Asked By: Nickotine

||

Using as reference this answer you can use wildcards in ssh client config file.

So config should be feasible but I will suggest to list explicitly as much as possible hosts

 host x* y* z*
  user duck
  identityFile ~/.ssh/

# for hosts one two three

host one 2 3
  user apple
  IdentityFile ~/.ssh/quack

Setting record like

host * 
user apple
IdentityFile ~/.ssh/quack

can sometime bring unexpected errors (because of the host wildcard interpretation)

Answered By: Romeo Ninov
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.