Adding an SSH key on Mac OSX or Linux is pretty straightforward and both Github and Gitlab come with official guides on the process of generating an ssh key and adding it to the agent.
Until a few years ago you were forced to install putty or a similar third party program to handle SSH keys the Linux way, but nowadays thanks to Microsoft
The process on Windows is pretty similar nowadays, it used to be way harder, but with windows adding support for Bash it has become way easier to do.
- Open Git Bash
cd ~/.ssh/to navigate to the SSH directory
- If you don’t have a key already in this directory make one using ssh-keygen
ssh-keygen -C "firstname.lastname@example.org"to generate a new key 3.2 Add a password if you wish (you should)
eval \$(ssh-agent), it will load the SSH agent for the session
ssh-add ~/.ssh/id_rsato add the key to the agent. If you’ve set up a key before you will be asked to type it in.
Now you can open the public file located at ~/.ssh/id_rsa.pub:
cd ~/.sshto navigate to the directory of the file
cat id_rsa.pubto print the content of the public key in the terminal window. Copy it and paste it in either Gitlab, Github, Linode, Digital Ocean or any other site using SSH authentication. Obviously, you will need to add your public key to the SSH settings in each site. Make sure NOT to add the private key, but only the public one (the file ending with .pub).
You can now push/pull from your private repositories or connect using SSH to your VPS.