Search code examples
sshssh-config

Is it possible to define mutiple Hosts in SSH Config File?


I am new to this. I do not find if this question has been asked. I am using CYGWIN for Windows. I have already created a working shortcut for one of my sites to make the SSH easy. I have done the following

Host shortcut    
  HostName hostname.com
  User ubuntu    
  IdentityFile "~/.ssh/path-to-file.pem"

Now I want to do this to another site with a long host name. Is it possible to define it in the same config file, or should it be done in new file? Or is it impossible?


Solution

  • It can be defined in the same config. It looks like the following example

    Host shortcut
      HostName hostname.com
      User ubuntu
      IdentityFile ~/.ssh/path-to-file.pem
    
    Host shortcut2
      HostName hostname2.com
      User ubuntu
      IdentityFile ~/.ssh/path-to-file2.pem