Wie kann ich einige Einstellungen auf einen SSH-Host anwenden und dabei einen anderen Host ausschließen?

Wie kann ich einige Einstellungen auf einen SSH-Host anwenden und dabei einen anderen Host ausschließen?

Ich habe ein relativ vollständiges Setup für mein ~/.ssh/config. Das steht ganz oben:

Host *
   ControlMaster auto
   ControlPath /tmp/ssh_mux_%h_%p_%r
   ControlPersist 24h
   BatchMode yes
   Ciphers blowfish-cbc
   Compression yes
   VisualHostKey yes

Ich möchte es so machen, dass ControlMasterusw. nicht auf GitHub zutrifft. Sie trennen diese dauerhaften Verbindungen anscheinend aktiv, was ich verstehe und respektiere.

Um es klar zu sagen:

 $ rm /tmp/ssh_mux_*
 $ ssh [email protected]
   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

Ich habe also ein paar Dokumente gelesen und im IRC nachgefragt. Das hier ist dabei herausgekommen:

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

Host *
   BatchMode yes
   Ciphers blowfish-cbc
   Compression yes
   VisualHostKey yes

Daher verwendet GitHub jetzt korrekterweise ControlMaster nicht:

 $ rm /tmp/ssh_mux_*
 $ ssh [email protected]
   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_*

Aber auch sonst nichts:

 $ 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_*

Ich habe versucht, die Host-Zeile zu erstellen Host !github.com, *, Host *, !github.comaber soweit ich das beurteilen kann, gilt dies immer für GitHub.

Wie kann ich tun, was ich will?

Antwort1

Die folgenden Muster Hostwerden durch Leerzeichen und nicht durch Kommas getrennt, daher sollte Folgendes funktionieren:

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

Antwort2

rudi_s im IRC hat mir geholfen, die Lösung zu finden:

Host github.com
   ControlMaster  no
   ControlPath    no
   ControlPersist no

Host *
   ControlMaster auto
   ControlPath /tmp/ssh_mux_%h_%p_%r
   ControlPersist 24h
   BatchMode yes
   Ciphers blowfish-cbc
   Compression yes
   VisualHostKey yes

verwandte Informationen