如何将某些设置应用于不包括其他主机的 ssh 主机?

Fre*_*idt 4 ssh

我的~/.ssh/config. 这是顶部的内容:

Host *
   ControlMaster auto
   ControlPath /tmp/ssh_mux_%h_%p_%r
   ControlPersist 24h
   BatchMode yes
   Ciphers blowfish-cbc
   Compression yes
   VisualHostKey yes
Run Code Online (Sandbox Code Playgroud)

我想让它等ControlMaster不适用于 github;他们显然主动断开了这些持久连接,我理解并尊重它们。

所以要明确:

 $ rm /tmp/ssh_mux_*
 $ ssh git@github.com
   PTY allocation request failed
   Hi frioux! You've successfully authenticated, but GitHub does not provide shell access.
   Shared connection to github.com closed.

 $ ls /tmp/ssh_mux_*
   /tmp/ssh_mux_github.com_22_git
Run Code Online (Sandbox Code Playgroud)

所以我阅读了一些文档,我在 IRC 中询问,这就是我最终得到的结果:

Host !github.com
   ControlMaster auto
   ControlPath /tmp/ssh_mux_%h_%p_%r
   ControlPersist 24h

Host *
   BatchMode yes
   Ciphers blowfish-cbc
   Compression yes
   VisualHostKey yes
Run Code Online (Sandbox Code Playgroud)

所以现在github正确地不使用ControlMaster:

 $ rm /tmp/ssh_mux_*
 $ ssh git@github.com
   Host key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
   +--[ RSA 2048]----+
   |        .        |
   |       + .       |
   |      . B .      |
   |     o * +       |
   |    X * S        |
   |   + O o . .     |
   |    .   E . o    |
   |       . . o     |
   |        . .      |
   +-----------------+

   PTY allocation request failed
   Hi frioux! You've successfully authenticated, but GitHub does not provide shell access.
   Shared connection to github.com closed.

 $ ls /tmp/ssh_mux_*
Run Code Online (Sandbox Code Playgroud)

但也没有其他任何事情:

 $ rm /tmp/ssh_mux_*
 $ ssh cs ls
   Host key fingerprint is 89:d1:40:7f:0d:11:28:10:ce:23:e6:a9:12:9d:a1:5b
   +--[ RSA 2048]----+
   |    o+o  .+o     |
   |   o  .+.  o     |
   |  + + ..o . .    |
   | = = . o o       |
   |o E   . S        |
   | =               |
   |+                |
   |.                |
   |                 |
   +-----------------+

   /home/frew
   bin
   code
   irclogs
   lib
   out
   test

 $ ls /tmp/ssh_mux_*
Run Code Online (Sandbox Code Playgroud)

我尝试制作主机线Host !github.com, *Host *, !github.com但据我所知,它始终适用于 github。

我怎样才能做我想做的事?

小智 9

后面Host的模式用空格分隔,而不是逗号,所以这应该有效:

Host * !github.com
    ControlMaster auto
    ControlPath /tmp/ssh_mux_%h_%p_%r
    ControlPersist 24h
Run Code Online (Sandbox Code Playgroud)