git ssh密钥配置添加

1.  初次安装git配置用户名和邮箱

$ git config --global user.name "xxx"

$ git config --global user.email "xx@163.com"

2. git使用ssh密钥

$ ssh-keygen -t rsa -C "xxx@126.com"

git   ssh密钥配置添加

3.生成密钥对

cat ~/.ssh/id_rsa.pub

ssh-rsa B3NzaC1yc2EAAAADAQABAAABAQDDLFAvtyxdR0TGyLHsSDFk/PjBbG2QIqNiyuStWrOy1bjL/c615lLjWS26zVf++zI6d7Vdcfrc/L7YRMng099O3CunXVYmlaRJj5Uii0IW6/dFZPmCa2QtAOvuJRJLGKtGLa6vxvqMwvUzsvHz64QCzXIotcFlewKKTlRvrxArOuwEskgcX7/Vr71XZoaz72Bs4LSTZ6NQPrfkbb6ku0hws9ERy2wtnoSpo2wkXkODvdzpDtuxAIYQhxnLEMHyWkvCG9RVW6UDkHWpf9+KbJWzKz9g0I1CC58iDP3BBkr/O+hBT7/inFSD

4. 添加公钥到你的远程仓库(github)

远程添加完后验证

$ ssh -T git@github.com
Hi xxx! You've successfully authenticated, but GitHub does not # provide shell access.

成功

  

5、修改git的remote url
$ git remote -v
origin https://github.com/someaccount/someproject.git (fetch)
origin https://github.com/someaccount/someproject.git (push)

  

上一篇:git ssh密钥的使用


下一篇:Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again 解决方法