This article is about using SSH for a secure connection between our computer and git server.

Now the reason for doing this is because HTTPS auth requires a user name and password over the connection and this service sends these credentials with a request every time which makes it insecure even with HTTPS. Now as a workaround of using an Access Token is secure for time but it has a session that can run for a limited time which requires you to set it up again and ask for auth again.

So as a resolution git servers allow us to set up SSH public-private key pairs for effortless and always available connections.

To do that simply go to your GitLab account (https://c.helpusdefend.com/) and log in with your user name and password.

Once you logged in you should be able to see a drop-down arrow at the top-right corner of the screen, click that and select preferences.

After navigating to preferences, you will have a list of options in the left side menu column. Select SSH keys from there. Now here we just need to add a public key that is generated by our SSK client (Which is a tricky part).

To do that we have two ways, either use the existing key that we have in our computer or create a new one. Reusing the existing key is easy and for that, you can simply search "How to locate SSH public key" and you will get plenty of results with the command to use in the terminal that can give your results. But for generating new key pair follow as mentioned below.

Go to the terminal and enter the command, "<comment>" can be anything, what I enter is "git_username_platform" since this one credential can work for every project:

ssh-keygen -t ed25519 -C "<comment>" 
After entering this command, it might ask you for a file name but by ignoring it, you can choose the default file name. After that, the terminal will ask you for a "Passphrase", which is a password for accessing the SSH key later. 

Once you are finished with this wizard, you will have a file with extension ".pub" (Don't use another file with the same name because it has a private key which you need to keep safe and not expose it in any means) which contains your public key to us in git server.

For more information and demonstration check the following links:

Video: https://www.youtube.com/watch?v=mNtQ55quG9M&t=12s
Blog: https://c.helpusdefend.com/help/ssh/README#generate-an-ssh-key-pair (Can only be used after login).

Note: SSH key generation is recommended doing with ED25519 and not RSA, especially RSA MD5, it's not secure.


If you are not comfortable using git using the command line interface, I suggest using any GUI app that you like and most of the app supports SSH auth for your account. The one I am using is named “Fork” which can be found below.

Fork: https://git-fork.com/