Navigate to ~/.ssh
and if using Windows and git bash go to C:\Users\<user>\.ssh
Create a file named config
in following format
Host *.someurl.com
IdentityFile ~/.ssh/my_key
In this example *
(star) is for everything. Now to connect do ssh ubuntu@abc.someurl.com
.
Some more examples of ssh config file.
Host someurl.com
IdentityFile <path to private key>
Host <ip address>
IdentityFile <path to private key>
You can further define config to save time connecting to machines
Host dev
HostName dev.mysite.com
IdentityFile <path to private key>
User ubuntu
Host stage
HostName stage.mysite.com
IdentityFile <path to private key>
User <username>
And directly connect with ssh dev
or ssh stage
.
Top comments (0)