git clone [email protected]:goecho/home/kali/Music/aic8800_linux_drvier.git Cloning into 'aic8800_linux_drvier'... [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
时间: 2025-09-10 08:10:28 AIGC 浏览: 4
当使用 `git clone` 命令克隆 `[email protected]:goecho/home/kali/Music/aic8800_linux_drvier.git` 仓库时出现 `Permission denied (publickey)` 错误,可尝试以下解决办法:
#### 检查本地 SSH 密钥
查看本地是否已经存在 SSH 密钥。SSH 密钥通常存放在 `~/.ssh` 目录下,使用以下命令查看:
```bash
ls -al ~/.ssh
```
若该目录下存在 `id_rsa.pub` 或 `id_ed25519.pub` 等公钥文件,则表示已经存在 SSH 密钥;若没有,则需要生成新的 SSH 密钥。
#### 生成新的 SSH 密钥
若本地没有 SSH 密钥,使用以下命令生成:
```bash
ssh-keygen -t ed25519 -C "[email protected]"
```
按提示操作,设置密钥保存路径和密码(密码可以为空)。生成成功后,会在 `~/.ssh` 目录下生成私钥(如 `id_ed25519`)和公钥(如 `id_ed25519.pub`)。
#### 将公钥添加到 GitHub 账户
1. 复制公钥内容。可使用以下命令复制公钥到剪贴板(Linux/macOS):
```bash
cat ~/.ssh/id_ed25519.pub | pbcopy # macOS
cat ~/.ssh/id_ed25519.pub | xclip -sel clip # Linux
```
在 Windows 系统中,可使用文本编辑器打开 `~/.ssh/id_ed25519.pub` 文件,手动复制内容。
2. 登录 GitHub 账户,点击右上角头像,选择 `Settings`。
3. 在左侧菜单中选择 `SSH and GPG keys`。
4. 点击 `New SSH key`,在 `Title` 中输入一个名称,用于标识该密钥;在 `Key` 字段中粘贴之前复制的公钥内容。
5. 点击 `Add SSH key` 保存设置。
#### 配置 SSH 客户端
编辑 `~/.ssh/config` 文件(若文件不存在,则创建它),添加以下内容:
```plaintext
Host github.com
HostName github.com
IdentityFile ~/.ssh/id_ed25519
PreferredAuthentications publickey
User git
```
确保 `IdentityFile` 指向之前生成的私钥文件。
#### 测试 SSH 连接
使用以下命令测试 SSH 连接是否正常:
```bash
ssh -T [email protected]
```
若出现 `Hi username! You've successfully authenticated, but GitHub does not provide shell access.` 则表示连接成功。
#### 再次尝试克隆仓库
完成以上步骤后,再次使用 `git clone` 命令克隆 GitHub 仓库,应该可以正常克隆。
阅读全文
相关推荐




















