上QQ阅读APP看书,第一时间看更新
There's more...
You might have noticed that in my examples, I used a mixture of upper and lower characters for my names (for example, CentOS2-V4). I do this because it means that I know when I'm using my SSH config file, and can be sure at a glance that I'm using the settings I configured.
There's nothing stopping you from creating a block like so:
Host centos2
Hostname 192.168.33.11
User vagrant
This is perfectly valid, and the settings will be read as normal.
You can also do clever things such as specific domain matching. If you have to manage two different sets of servers differentiated by their domains, you can do the following:
Host *.examplecake.com
Port 2222
User Alie
Host *.examplebiscuit.co.uk
Port 5252
User Gingerbread
Attempting to connect to hosts in either of these domains will result in specific configuration options being used:
[vagrant@centos1 ~]$ ssh -v potato.examplecake.com
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /home/vagrant/.ssh/config
debug1: /home/vagrant/.ssh/config line 1: Applying options for *
debug1: /home/vagrant/.ssh/config line 19: Applying options for *.examplecake.com
debug1: Reading configuration data /etc/ssh/ssh_config