创建码云账号并添加公钥
git config --global user.name "wanghaima" # 配置全局的名称
git config --global user.email "whm2416@qq.com" # 配置全局的邮箱
# 查看生成的配置文件.gitconfig
cat ~/.gitconfig #linux环境
cat C:\Users\Administrator\.gitconfig # windows10
# 运行命令,生成公钥,私钥
ssh-keygen -t rsa -C "whm2416@qq.net" ,然后一直回车
# 查看生成的公钥
cat ~/.ssh/id_rsa.pub #linux环境
cat C:\Users\Administrator\.ssh\id_rsa.pub # windows
测试是否配置成功
完成后可以在命令行测试是否配置成功,首次建立链接会要求信任主机
ssh -T git@github.com //github
ssh -T git@gitee.com //码云
在服务器添加完公钥后报错
sign_and_send_pubkey: signing failed: agent refused operation
haima@haima-PC:~/go/src/haimait/gin_web$ ssh -T git@github.com
sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey).
haima@haima-PC:~/go/src/haimait/gin_web$ eval "$(ssh-agent -s)"
Agent pid 25192
haima@haima-PC:~/go/src/haimait/gin_web$ ssh-add
Identity added: /home/haima/.ssh/id_rsa (/home/haima/.ssh/id_rsa)
haima@haima-PC:~/go/src/haimait/gin_web$ ssh -T git@github.com
Hi haimait! You've successfully authenticated, but GitHub does not provide shell access.
先注册账号
生成公钥
把公钥粘到码云
测试公钥是否可以使用
[Haima的博客]
http://www.cnblogs.com/haima/