Pages

Friday, November 27, 2015

[git] Add ssh key to github account using command line

To push commits onto the remote repository hosted on your github account without password, your need to add your ssh key. Such process can be easily done using a web browser. In this post I will write down how to achieve this via command line.

In the following example, I assume the following"
1. Your github account is spencer
2. You want to label your ssh key on github as myLaptop
3. You know how to get your ssh key

Step 1: Connect to the api using curl
curl -u spencer https://api.github.com

Step 2: Post your key
curl -u spencer -data '{"title":"myLaptop","key":"ssh-rsa blahblahblah"}' https://api.github.com/user/keys


No comments:

Post a Comment