gitcode 提交代码,遇到 Permission denied (publickey). 如何解决

本文档详细介绍了如何在Gitcode上创建并托管私人项目,包括生成SSH公钥、添加公钥到Gitcode以及解决gitpush权限问题的步骤。通过这些操作,你可以顺利地将本地代码推送到Gitcode的私有仓库中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 最近开发了一个小项目,想提交到 csdn 下的 gitcode 上进行托管,由于是个人项目,可以在 gitcode 上创建一个私人项目

https://gitcode.net/

 

选择私有项目即可。

接着在自己的代码安装帮助文档进行操作,注意马赛克部分是自己的内容。

根据文档,在最后一步 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   

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值