git config ssh
tags (space delimited): git
1. Set git's user name and email: (If it's the first time)
$ git config--global user.name "weiguobing"
$ git config--global user.email "guobingwei@aliyun.com"
2. Generate key
$ ssh-keygen-t rsa-c "Humingx@yeah.net"
3 consecutive carriage returns. If you don't need a password.
Finally, two files were obtained: Id_rsa and id_rsa.pub.
3. Add encryption Key to Ssh-agent
Make sure that the ssh-agent is available. Ssh-agent is a program that controls the private key used to hold public key authentication, in fact Ssh-agent is a key manager, after running ssh-agent, use Ssh-add to give the private key to ssh-agent custody, Other programs that require authentication can pass the validation request to Ssh-agent to complete the certification process.
Start the ssh-agent in the background
eval "$ (ssh-agent-s)"
Agent PID 59566
Add the generated SSH key to Ssh-agent.
$ Ssh-add ~/.ssh/id_rsa
4. Login to GitHub and add ssh.
5. Test:
$ ssh-t git@github.com
6. Modify the URL of the. git folder under CONFIG.
Before modification:
[remote "origin"]
url = https://github.com/humingx/humingx.github.io.git
fetch = +refs/heads/*:refs/remotes/origin/*
After modification:
[remote "origin"]
url = git@git.oschina.net:humingx/humingx.github.io.git
fetch = +refs/heads/*:refs/remotes/origin/*
It's done.