SSH is a safer and easier way to establish connection to a server instead of using username and password.
In Mac OSX terminal, check if any SSH key is exist
If no SSH key available, generate one
ssh-keygen -t rsa
You need to confirm on the location to save, and whether to use passphrase or not
Then you can copy paste the SSH key to the server you want to connect to
Normally the settings of SSH tied to user account (check under user profile settings > SSH). Not under individual repository
— Another note on creating SSH key —
- == Generating a new SSH key ==
1. Open Git Bash or Command Prompt (Windows) or Terminal (Mac/Linux).
2. Paste the text below, substituting in your GitLab email address.
ssh-keygen -t rsa -b 4096 -C “firstname.lastname@example.org”
This creates a new ssh key, using the provided email as a label.
Generating public/private rsa key pair.
3. When you’re prompted to “Enter a file in which to save the key,” press Enter. This accepts the default file location.
Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]
4. At the prompt, type a secure passphrase. For more information, see “Working with SSH key passphrases”.
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
== Set SSH Public key in GitLab ==
1. Open gitlab.com and go to Settings.
2. Open SSH Keys tab and add new key:
Key : [Paste SSH Public key (id_rsa.pub) not Private key]
Title : [It should display barracudacampus email after you’ve pasted the key]
3. Click *Add key*
== Use SSH key in SourceTree ==
1. Open SourceTree and click on *Tools > Options > General*
2. Go to SSH Client Configuration and update following field:
SSH Key : [Select id_rsa file generated previously]
SSH Client : OpenSSH
3. Click *OK*