I have an .ssh/config file that gives several names for the same remote host, e.g.:-

Host cheddar
HostName cheddar.halon.org.uk
Host halon
HostName cheddar.halon.org.uk

Then I have an entry for cheddar.halon.org.uk which specifies various things for that host. I was expecting that the configuration at the cheddar.halon.org.uk would get executed when I used 'cheddar' or 'halon' for the ssh connection but it doesn't. The cheddar.halon.org.uk configuration only gets set when I do 'ssh cheddar.halon.org.uk'.

Is there any way to get the same configuration when using a number of different names for a host?

  • 1
    At least with OpenSSH, the Host key accepts a whitespace separated list (or even a pattern). So you can use a single Host cheddar halon line followed by common settings. Maybe that would help? – steeldriver Jan 10 at 20:38
  • Yes, youi're absolutely right, that's the way to do it. – Chris Green Jan 11 at 13:44
  • Yes, you're absolutely right, that's the way to do it. I now have:- Host cheddar.halon.org.uk cheddar halon PermitLocalCommand yes # LocalCommand echo "Local command runs" >/tmp/lc LocalCommand rsync --update -a -e "ssh -o PermitLocalCommand=no" ~/.cfg/ halon:.cfg/ & Hostname cheddar.halon.org.uk – Chris Green Jan 11 at 14:59
  • ... and I can't get the hang of using markdown to indicate code! :-) – Chris Green Jan 11 at 15:00
  • Markdown is limited in comments - you might want to consider posting your successful config as a self-answer instead – steeldriver Jan 11 at 15:18

OK, here's the answer to my specific requirement. As noted above in the comments, one can put more than one name in the Host line:

Host cheddar.halon.org.uk cheddar halon
    Hostname cheddar.halon.org.uk

Very simple!

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.