首页 > 技术文章 > 使用公钥访问码云

missile 2019-03-13 21:32 原文

1.本地进入.ssh查看是否存在密钥对:xxx和xxx.pub

命令:cd ~/.ssh

2.如果不存在,使用ssh-keygen来创建

命令:ssh-keygen -t rsa -C "youremail@youremail.com"
例如:ssh-keygen -t rsa -C "wanwan5856@163.com"
注解:
Enter file in which to save the key 输入保存秘钥的文件 直接enter即可
Enter passphrase (empty for no passphrase) 输入密码 直接enter即可
此时查看.ssh目录下可看到新增的一对秘钥id_rsa和id_rsa.pub

3.把id_rsa.pub中的公钥复制到gitee设置-安全设置-ssh公钥中

4.如果以前是使用https下载的代码需要把https切换到ssh

git remote set-url origin 仓库ssh地址

推荐阅读