Create shortcuts for frequently accessed servers
January 19, 2021 Leave a comment
Life is too short, that’s why it’s mandatory to use shortcuts… Instead of typing frequently used ssh client options such as port, user, hostname, identity-file and so on, you can save that information in sshd config file and then access it with defined alias.
- System wide config file location is
/etc/ssh/ssh_config
- User specific config file location is
~/.ssh/config
same as$HOME/.ssh/config
Instead of connecting to the server everytime using the following command:
# ssh root@95.80.12.10 -i ~/.ssh/my_id_rsa
Save the following entries in ~/.ssh/config
file:
# vim ~/.ssh/config
Host my_db
HostName 95.80.12.10
IdentityFile ~/.ssh/my_id_rsa
User root
And connect to the server using this simple way:
# ssh my_db
For other options check https://linuxize.com/post/using-the-ssh-config-file/