$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
2. Paste the content in the id_rsa.pub
file to github setting page
$ cat ~/.ssh/id_rsa.pub
First start the ssh-agent in the background.
$ eval "$(ssh-agent -s)"
Then add your SSH private key to the ssh-agent.
$ ssh-add ~/.ssh/id_rsa
$ ssh -T git@github.com
If successed, it will output: Hi <Github username> You've successfully authenticated, but GitHub does not provide shell access.
If you use several keys, then you need to config your ssh as follow:
$ cd ~/.ssh/
$ vim config
Input the following content, replace the ~/.ssh/id_rsa with your private key file for your github account.
Host github.com
IdentityFile ~/.ssh/id_rsa
Setting up the configuration details of git Note that the username here is NOT the GitHub user name
$ git init # First create an empty Git repository on local
$ git config --local user.name "<user_name>"
$ git config --local user.email "<email_id>"
or for global
$ git config --global user.name "<user_name>"
$ git config --global user.email "<email_id>"
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin <ssh_target>
$ git push -u origin master
Each time before push