GitHub Clone
Switch Repository from HTTPS to SSH
Copoy the public from your laptop using the below command:
1
cat ~/.ssh/id_rsa.pub
If there is not key present, create a new ssh key using the below commands and provide the inputs requesting during creation (file path and passphrase):
Be careful of overriding any existing keys saved to the default location ~/.ssh/.
1 2 3 4 5
$ ssh-keygen -t rsa -b 4096 -C "your-email@yourdomain.com" Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/your.user/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again:
Once the key is generated, copy the content of the public key using the command provided in step 1.
Upload the key to your github profile:
a. Navigate to Github.com -> Login -> Click on your Profile Picture (top right) -> Settings b. Click on SSH and GPG Keys -> New SSK Key c. Provide a friendly name and paste the copied content of the public key. d. Click on Add SSH key
Clone the github repository using the SSH URL:
1
git clone git@github.com:<profilename>/<reponame>.github.io.git
Switch from HTTPS to SSH Authentication
- Confirm if the current authentication to your github repository is using HTTPS:
1 2 3
$ git remote -v origin https://github.com/<profilename>/<reponame>.github.git (fetch) origin https://github.com/<profilename>/<reponame>.github.git (push)
- Remove the existing remote origin whcih contains the https configuration:
1
git remote rm origin
- Add the new remote origin wiht the new ssh configuration:
1
git remote add origin git@github.com:<prfilename>/<reponame>.github.git
- Confirm if the git has changed to new ssh conighration:
1 2 3
$ git remove -v origin git@github.com:<profilename>/<reponame>.github.io.git (fetch) origin git@github.com:<profilename>/<reponame>.github.io.git (push)
This post is licensed under CC BY 4.0 by the author.