最近开发了一个小项目,想提交到 csdn 下的 gitcode 上进行托管,由于是个人项目,可以在 gitcode 上创建一个私人项目
选择私有项目即可。
接着在自己的代码安装帮助文档进行操作,注意马赛克部分是自己的内容。
根据文档,在最后一步 git push 遇到错误。
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitcode.net,119.3.229.170' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
这是因为秘钥检测不通过,需要做的是在客户端上生成公钥,将公钥上传到 gitcode 上即可。
执行命令 ssh-keygen -t rsa -b 2048 -C "email@example.com" 一路回车
[root@sip5060 code]# ssh-keygen -t rsa -b 2048 -C "email@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:mNwU8uW1EDodFSg9lpvdrvhfOTdK9o4uSzpRvqkUWqc email@example.com
The key's randomart image is:
+---[RSA 2048]----+
| . ..==+. |
| o.**+ . |
| =oo=.. |
| . = .o.. . |
| + Soo. . |
| o.+. . .|
| . E.oo+ +o|
| ..+++ +.+|
| ooo==oo |
+----[SHA256]-----+
会自动生成 /root/.ssh/id_rsa.pub 公钥文件
cat 文件,拷贝文件内容,登录 gitcode
进入个人主页,选择个人设置
在右侧粘贴公钥,添加。
最后回到客户端重新 git push 就发现可以提交了。
测试过程中可以通过命令检测连接 ssh -vT git@gitcode.net