I have a added a local proxy for all my hosts in my .ssh config, however I want to shell into my local vm without the proxy command. Output of my ssh attempt:

debug1: /Users/bbarbour/.ssh/config line 1: Applying options for local.dev
debug1: /Users/bbarbour/.ssh/config line 65: Applying options for *

Given the following ssh config how do I prevent the ProxyCommand from being applied to the local.dev entry?

Host local.dev
    HostName dev.myserver.com
    User developer
Host *
    ProxyCommand /usr/local/bin/corkscrew 8840 %h %p

2 Answers 2


You can exclude local.dev from ProxyCommand, using ! before it:

Host * !local.dev
    ProxyCommand /usr/local/bin/corkscrew 8840 %h %p

From ssh_config documentation:

If more than one pattern is provided, they should be separated by whitespace.

A pattern entry may be negated by prefixing it with an exclamation mark (`!'). If a negated entry is matched, then the Host entry is ignored, regardless of whether any other patterns on the line match. Negated matches are therefore useful to provide exceptions for wildcard matches.

The documentation also said:

For each parameter, the first obtained value will be used. The configuration files contain sections separated by ``Host'' specifications, and that section is only applied for hosts that match one of the patterns given in the specification. The matched host name is the one given on the command line.

So, you can also disable ProxyCommand for local.dev by override value that you have defined in Host *:

Host local.dev
    HostName dev.myserver.com
    User developer
    ProxyCommand none

An option in the config file is applied the first time it matches. Since you don't have any ProxyCommand in the host entry, the one in your * entry will be used.

There are two ways to get around this:

  • For the hosts where you don't want to use the proxy command, simply add the line
    ProxyCommand none
  • For the * entry, note specifically that the entry should not apply to the host local.dev by negating it with a !
    Host !local.dev *
  • to separate multiple hosts use space. comma(,) did not work for me. Distributor ID: Ubuntu Description: Ubuntu 17.10 Release: 17.10 Codename: artful
    – Aruna
    Mar 25, 2018 at 21:29
  • Thanks @ArunaFromLK - I can't believe I missed that, and that nobody else has spotted it in 3,5 years! I've updated the answer now.
    – Jenny D
    Mar 26, 2018 at 6:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .