Skip to content

Instantly share code, notes, and snippets.

@jamal919
Created July 29, 2018 09:40
Show Gist options
  • Save jamal919/2fd3be7294f350adae7fd448cceb40d0 to your computer and use it in GitHub Desktop.
Save jamal919/2fd3be7294f350adae7fd448cceb40d0 to your computer and use it in GitHub Desktop.
SSH authentication in github

Create a repo and make some file

Generate ssh key:

ssh-keygen -t rsa -C "your_email@example.com"

Copy the contents of the file ~/.ssh/id_rsa.pub to your SSH keys in your GitHub account settings. Test SSH key:

ssh -T git@github.com
clone the repo:
git clone git://github.com/username/your-repository

Now cd to your git clone folder and do:

git remote set-url origin git@github.com:username/your-repository.git

If you give a different name of the ssh id file then it is better to set an entry in .ssh/config file as follows -

Host <hostname>
  HostName github.com
  User <username>
  IdentityFile ~/.ssh/<identityfile>

In this case on you git folder do the following -

git remote set-url origin git@<hostname>:username/your-repository.git

Now try editing a file and then do:

git add -A
git commit -am "update message"
git push

Please be careful about your RSA ids.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment