As an enthusiastic developer, there are times when I need to collaborate with other people on projects that hosted in a central repository such as GitHub, Bit Bucket, or Gitlab.
Without the need to always type in the password on push, I need to add my SSH Key to that repository the enable it to recognize my development machine. In my case, I use mac.
Generating the key
In case you’re on a brand new Macbook and which has not yet generated a key before. To generate, open the terminal and run the following command:
ssh-keygen -t rsa -b 4096
Hit enter to accept the default location. Then once it prompts you to enter a passphrase, enter it or leave it blank to never require a passphrase on committing to the remote repository.
The next step is to copy the key and use it at your repository’s account profile.
Copying the key
Open the terminal and run the following command:
pbcopy < ~/.ssh/id_rsa.pub
Add SSH Key to the SSH Authentication Agent
When my Mac is restarted, I lost my SSH authentication to the remote repository. We do not need to create a new separate secret key as it’s already there. It happens because the SSH Authentication Agent lost it. To add it, run the following command in the terminal:
The we’ll get the confirmation message saying that the Identity was added.
Identity added: /Users/vannkorn/.ssh/id_rsa