Git使用之Permission Denied问题解决

简介:

今天碰到了Git的Permission Denied问题。

在安装好git之后,我们一般会配置用户名和邮箱

git config --global user.name "zengjinlong" #--global表明本机的所有git仓库均使用该配置

  git config --global user.email "zengjinlong@xunlei.com"  

但是当我们克隆一个库的时候,发现不论你怎么输入密码都是说Permission Denied。

其实,这是你没有生成公钥

找到这个页面:


SSH Keys


SSH key allows you to establish a secure connection between your computer and GitLab


Before generating an SSH key, check if your system already has one by running cat ~/.ssh/id_rsa.pub If your see a long string starting with ssh-rsa or ssh-dsa, you can skip the ssh-keygen step.


To generate a new SSH key just open your terminal and use code below. The ssh-keygen command prompts you for a location and filename to store the key pair and for a password. When prompted for the location and filename you can press enter to use the default. It is a best practice to use a password for an SSH key but it is not required and you can skip creating a password by pressing enter. Note that the password you choose here can't be altered or retrieved.


ssh-keygen -t rsa -C "$your_email"
Use the code below to show your public key.


cat ~/.ssh/id_rsa.pub
Copy-paste the key to the 'My SSH Keys' section under the 'SSH' tab in your user profile. Please copy the complete key starting with ssh- and ending with your username and host.

很简单,就是用你的邮箱生成一个公钥,然后加入到你的代码管理网站中。然后在如下页面中加入SSH Key到项目中。

My SSH keys

SSH keys allow you to establish a secure connection between your computer and GitLab 
Before you can add an SSH key you need to generate it


然后再git clone 一次,发现可以了。好了。这个问题解决。


相关文章
|
缓存 开发工具 git
【git】解决:remote: Permission to xxxx/xxxx.git denied to xxxx
【git】解决:remote: Permission to xxxx/xxxx.git denied to xxxx
665 0
|
2月前
|
Unix Shell 网络安全
git学习六:(bug总结)git@github.com: Permission denied (publickey).等
本文是关于解决在使用Git和GitHub时遇到的“git@github.com: Permission denied (publickey)”错误的指南。文章提供了详细的步骤,包括确认SSH Agent运行状态、检查密钥配置、确保密钥匹配、验证仓库URL、检查权限和代理设置,以及配置SSH文件。这些步骤帮助用户诊断并解决SSH认证问题。
169 0
|
网络安全 开发工具 git
git clone之报错git@gitee.com:Permission denied (publickey).fatal: Could not read from remote repository
git clone之报错git@gitee.com:Permission denied (publickey).fatal: Could not read from remote repository
601 0
|
开发工具 git
解决Git push提交时Permission denied(publickey).Could not read from remote...的问题
解决Git push提交时Permission denied(publickey).Could not read from remote...的问题
319 0
|
7月前
|
网络安全 数据安全/隐私保护
解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Pleas
解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Pleas
1177 0
|
开发工具 git
在modelscope中,使用git下载一直显示access denied
remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See https://modelscope.cn/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied fatal: Authenticati
|
存储 前端开发 网络安全
前端项目实战拾贰-git@github.com: Permission denied (publickey).
前端项目实战拾贰-git@github.com: Permission denied (publickey).
55 0
|
开发工具 数据安全/隐私保护 git
git 报错:remote: HTTP Basic: Access denied
git 报错:remote: HTTP Basic: Access denied
228 0
git 报错:remote: HTTP Basic: Access denied
|
开发工具 git
git remote: Permission to denied
git remote: Permission to denied
255 0
git remote: Permission to denied
|
开发工具 git
error: could not lock config file .git/config: Permission denied/Command failed with exit 255
error: could not lock config file .git/config: Permission denied/Command failed with exit 255
418 0