As you may have used bash or other shells, there is a powerful tool called wildcard which allows you
to perform actions on more than one file at a time. When you want to list all files in the directory start with foo
, you can use this:
1 | ls foo* |
Consider that you have a bulk of machines like this(just fake hosts):
机器名 | IP | 端口 | 用户名 | 密钥 |
---|---|---|---|---|
gg-android01-node.xx.yy.zz | 48.132.144.01 | 22000 | corvo | ~/.ssh/id_rsa_test |
gg-android02-node.xx.yy.zz | 48.132.144.02 | 22000 | corvo | ~/.ssh/id_rsa_test |
gg-android03-node.xx.yy.zz | 48.132.144.03 | 22000 | corvo | ~/.ssh/id_rsa_test |
gg-android04-node.xx.yy.zz | 48.132.144.04 | 22000 | corvo | ~/.ssh/id_rsa_test |
ms-vscode01-master.xx.yy.zz | 42.188.144.01 | 22000 | corvo | ~/.ssh/id_rsa_test |
ms-vscode02-master.xx.yy.zz | 42.188.144.02 | 22000 | corvo | ~/.ssh/id_rsa_test |
ms-vscode03-master.xx.yy.zz | 42.188.144.03 | 22000 | corvo | ~/.ssh/id_rsa_test |
fb-react01-teer.xx.yy.zz | 59.143.138.01 | 22000 | corvo | ~/.ssh/id_rsa_test |
fb-react02-teer.xx.yy.zz | 59.143.138.02 | 22000 | corvo | ~/.ssh/id_rsa_test |
fb-react03-teer.xx.yy.zz | 59.143.138.03 | 22000 | corvo | ~/.ssh/id_rsa_test |
When you want to put them in ssh_config
, it seems that you have to write the configuration this way, using a separate configuration for each host.
1 | Host android01 |
It’s not an elegant way, This configuration is full of duplicates of the same user and the same port: Here is a beautiful style:
1 | Host gg-* ms-* fb-* |
Now you can log in to your host directly with ssh.
1 | ~ ❤ ssh fb-react03-teer.xx.yy.zz |