码云提供了基于SSH协议的Git服务,在使用SSH协议访问仓库仓库之前,需要先配置好账户/仓库的SSH公钥。
你可以按如下命令来生成 sshkey:
//终端定位到项目文件夹
ssh-keygen -t rsa -C "123456789@qq.com"
Generating public/private rsa key pair.
//保存地址,默认就好,回车
Enter file in which to save the key (/Users/healer/.ssh/id_rsa):
//是否配置密码:不配置,回车
Enter passphrase (empty for no passphrase):
//验证密码,回车
Enter same passphrase again:
Your identification has been saved in /Users/healer/.ssh/id_rsa.
Your public key has been saved in /Users/healer/.ssh/id_rsa.pub.
//查看 ~/.ssh/id_rsa.pub 文件内容,获取到你的 public key
cat ~/.ssh/id_rsa.pub
ssh-rsaXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX@qq.com
添加ssh key
验证Gitee账户密码
添加后,在终端(Terminal)中输入
ssh -T git@gitee.com
首次使用需要确认并添加主机到本机SSH可信列表。若返回 Hi XXX! You've successfully authenticated, but Gitee.com does not provide shell access. 内容,则证明添加成功。