Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a relatively full setup for my ~/.ssh/config. This is what's at the top:

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

I want to make it such that ControlMaster etc do not apply to github; they apparently actively disconnect these persistent connections, which I understand and respect.

So to be clear:

 $ 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

So I read some docs, I asked in IRC, and this is what I ended up with:

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

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

So now github correctly does not use 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_*

But neither does anything else:

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

I tried making the host line Host !github.com, * and Host *, !github.com but as far as I can tell when I do that it always applies to github.

How can I do what I want?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Patterns after Host are separated with spaces, not commas, so this should work:

Host * !github.com
    ControlMaster auto
    ControlPath /tmp/ssh_mux_%h_%p_%r
    ControlPersist 24h
share|improve this answer

rudi_s on IRC helped me come up with the solution:

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
share|improve this answer
    
The reason this works is because the Host <match> entries are parsed in order, so the first matching entry is used. I'm not familiar with the !<hostname> matching pattern, so can't say for sure why it doesn't work. I suggest that it might be a feature newer than your SSH client. –  Slartibartfast Mar 22 at 21:21
    
While this works, the other answer is what I was trying for and ends up with a more succinct solution so I'm gonna mark it as correct. –  Frew Mar 23 at 1:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.