How to Create SSH Hostname without /etc/hosts
September 11, 2023•55 words
The file /etc/hosts
in WSL is always overwritten by the contents from Windows every time when WSL start. Changes applied to it will be removed.
If using with SSH, a short hostname can be created in ~/.ssh/config
file.
For example, use server1
instead of server1.mycompany.com
:
Add to ~/.ssh/config
file:
Host server1
HostName server1.mycompany.com