Multiple level host alias in ssh config

Multiple level host alias in ssh config

My system admin manages a set of SSH configs for our remote servers, these configs are updated and pushed to my /etc/ssh/ folder regularly. However, host names in the managed ssh configs are too long to type (I'm lazy). Can I create host name aliases in my ~/.ssh/config? Note that this is not alias for HostName.

For example, my admin pushes configs to my /etc/ssh/ssh_config.d/ which look like this:

Host a.long.host.name
    HostName real-host-name.example.com
    ProxyCommand some proxy command
    ...

I want to give a.long.host.name a different, shorter name so I can type ssh foo instead of ssh a.long.host.name, I don't want to use shell alias because other commands like scp will need separate shell aliases.

I think ProxyCommand ssh -J localhost a.long.host.name would work, but localhost must be have sshd enabled, which I can't do.

答案1

"Host a.long.host.name" is an arbitrary name, it can be anything you like so long as it's not a duplicate or a reserved word etc. It is effectively an ssh config specific alias. User specific ssh configs will take precedence over system level configs in /etc/ssh/

相关内容