ssh
30台のサーバーのオプションを設定し、ファイルで同じ設定を使用しているとします.ssh
config
。
host XXX
HostName XXX.YYY.com
User my_username
Compression yes
Ciphers arcfour,blowfish-cbc
Protocol 2
ControlMaster auto
ControlPath ~/.ssh/%r@%h:%p
IdentityFile ~/.ssh/YYY/id_rsa
この30台の機械の間で変更される唯一のことはXXX
。
私のファイルで上記の構造を30回繰り返す以外に、マシンの範囲を定義する他の方法はありますかconfig
?
ベストアンサー1
ssh_config(5)
マニュアルページから:
Host Restricts the following declarations (up to the next Host key‐ word) to be only for those hosts that match one of the patterns given after the keyword. If more than one pattern is provided, they should be separated by whitespace.
...
HostName Specifies the real host name to log into. This can be used to specify nicknames or abbreviations for hosts. If the hostname contains the character sequence ‘%h’, then this will be replaced with the host name specified on the commandline (this is useful for manipulating unqualified names).
だから:
Host XXX1 XXX2 XXX3
HostName %h.YYY.com