DEV Community

Roy
Roy

Posted on

ssh can not resolve hostname in included config file

I used Include directive to include ssh config generated by vagrant ssh

vagrant ssh-config > ~/.ssh/vagrant.d/centos4k8s.config

add

Include vagrant.d/*

to ~/.ssh/config before the Host * section, but when I try to ssh into the guest, I get an error like

can not resolve hostname

Then I put the ssh config generated by vagrant in to the ~/.ssh/config directly (without the use of Include, I put it before any other directive), then it works ok

I noticed that I have Include directive in the included file

Host master-1                                                                                                                                                                                                      
Include /home/hi/.ssh/vagrant_config

and the content of vagrant_config is

Host *
    ControlPath ~/.ssh/controlmasters/%r@%h-%p
    ControlMaster auto
    ControlPersist 10m

maybe the duplicated Host * has caused the problem

I change back to use Include vagrant.d/*, but I put it in the first line of ~/.ssh/config, it also works

Top comments (0)