Change from HTTPS to SSH
There are basically 3 (or 4) steps to change from HTTPS to SSH.
Create your SSH key
To create your SSH key, use the following command:
ssh-keygen -t rsa -C "[email protected]"
The -C
flag stands for comment
and you can write whatever you want, I prefer to write my email.
Copy key
Copy the key to your clipboard, as we need to upload it to our git remote repository (Github, Gitlab, Azure, or whatever provider you use).
cat ~/.ssh/id_rsa.pub
Unless you specified a new location for the file, this is very it is located. Use the cat
command to print out the content and copy it manually.
Add key to remote host
You need to manually add the key to your remote git host. Every provider does this differently, but often it is accessible within the settings of the user.
Change to SSH
The final command to make the change work is to update your local repository to use SSH instead. You should replace this with the link to your specific repository.
git remote set-url origin [email protected]:USERNAME/REPOSITORY.git
Use git remote -v
to check if everything has updated correctly.