I'm trying to understand why SSH proxycommand isn't working. I have a SSH config file in a custom location as below.

vagrant@ansible:~$ cat ~/.ssh/cml-config
Host mgmt-lxc
  IdentityFile ~/.ssh/id_rsa
  User Rod

Host 10.255.0.*
  ProxyCommand ssh -W %h:%p mgmt-lxc

I can SSH to the jumphost and from there to another device.

vagrant@ansible:~$ ssh -F ~/.ssh/cml-config mgmt-lxc
Rod@mgmt-8Fe5bN$ ssh cisco@
Warning: Permanently added '' (RSA) to the list of known hosts.

           ( o o )
       Router: Core-1
                      Secured system for authorized users only.
       .oooO          Unauthorized access is strictly prohibited.
        (   )   Oooo. All activities may be logged and monitored.
      ---\ (----(   )--------------------------------------------
          \_)    ) /

However when I attempt to SSH directly to using the custom SSH key I get an error.

vagrant@ansible:~$ ssh -F ~/.ssh/cml-config cisco@
ssh: Could not resolve hostname mgmt-lxc: Name or service not known
ssh_exchange_identification: Connection closed by remote host

I'm running Ubuntu Xenial64.


Add -F /the/path/to/.ssh/cml-config in your ssh -W command used as ProxyCommand (I am not sure the ~ path will work here, so try it and maybe use the full path).

Because otherwise your ssh interactive command will run ssh -W ... mgmt-lxc but then it will have no configuration file to read to discover that mgmt-lxc is not a true name resolving but a nickname you used in your configuration file.

Or add mgmt-lxc in /etc/hosts or equivalent with its IPv4 address

Or put everything in .ssh/config instead, as it is the default and will simplify your usage.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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