Thus far, I have often used HTTPS authentication for my git repositories, but there is an easier way to connect with your remote server. It’s SSH authentication!
I was hastiest to set it up for a long time, but was I saving time not having it?
Well… Now I know I should do it much earlier!
How SSH authentication works? ?
SSH authentication is much better than using the password (even a looooooooong one). You don’t need to remember anything as you will only have a public key on your drive. This reduces big security risk for you and your projects.
To make it work, you have to create a key pair of public and private keys. When you have them, you just need to upload the public key to your server, and you will be able to authenticate your connection with it.
The only thing that will change here is a link to the repository.
In a previous post about setting up a repository for Unity project, I used HTTPS authentication link which looks like this: https://gaello@bitbucket.org/gaello/unitygitsetup.git.
For the same repository I can use SSH authentication and I can connect to the same repository with this link: git@bitbucket.org:gaello/unitygitsetup.git
How to set it up? ??
First, you need to create an SSH key with the RSA algorithm.
Depending on your platform you will use a terminal (MacOS / Linux), command prompt (Windows) or tools like Putty Key Generator on Windows.
Here is an article on Creating SSH keys through terminal/command prompt.
If you are using SourceTree on Windows, you can even create SSH key from there! Here is a little article how to do it.
Upload your SSH key to the server ?
Depending on the server you’re using, this part may look different. But the general rule would be to go to your account settings and find “SSH keys”. You should be able to add a new key over there.
I’m adding documentation for each of these popular servers:
Summary ?
Thanks to that small change, you and your projects will be safer, and you won’t need to use your password every time you use tools for git!
So tell me, are you going to change the authentication method for SSH? Or you’re using something else?
Let me know in the comment section below! And if you know someone that can get some help, share a link with him to this post. I’ll really appreciate that! ?
If you are interested in getting emails when I release a new post, sign up for the newsletter!
Hope to see you next time! ?