gpt4 book ai didi

git - 无法使用 ssh 克隆现有存储库,ssh 配置似乎没问题

转载 作者:太空狗 更新时间:2023-10-29 14:16:28 26 4
gpt4 key购买 nike

这是我的情况:我有两个私有(private) 存储库。

  • git@github.com:syra37fGIT/Angular.git
  • git@github.com:syra37fGIT/temp.git

目前我通过克隆为其中一个添加了一个 Remote 。

$ git remote -v
origin git@github.com:syra37fGIT/temp.git (fetch)
origin git@github.com:syra37fGIT/temp.git (push)

我认为 ssh 配置正确,因为:

我生成了私钥 (id_rsa) 和公钥 (id_rsa.pub)

$ ls -al ~/.ssh
total 28
drwxr-xr-x 1 Pietro 197121 0 Mar 5 00:18 ./
drwxr-xr-x 1 Pietro 197121 0 Mar 17 09:19 ../
-rw-r--r-- 1 Pietro 197121 3389 Mar 5 00:18 id_rsa
-rw-r--r-- 1 Pietro 197121 747 Mar 5 00:18 id_rsa.pub
-rw-r--r-- 1 Pietro 197121 2790 Mar 5 00:29 known_hosts

公钥已正确设置到我的 github 帐户个人设置/SSH 和 GPG key

public key setted on account

私钥似乎也正确注册

$ eval `ssh-agent -s`
Agent pid 7696

$ ssh-add
Identity added: /c/Users/Pietro/.ssh/id_rsa (syra37fGIT@yandex.com)

作为证明,我实际上可以毫无问题地将提交推送到添加的存储库中(因为 ssh 处于事件状态,因此不需要密码)

(master)$ echo -e "\ndamn u damn" > README.txt
(master)$ git add .
(master)$ $ git commit -m "damn u commit"
[master dae7dfd] damn u commit
1 file changed, 2 insertions(+), 4 deletions(-)
(master)$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 263 bytes | 263.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:syra37fGIT/temp.git
54bc492..dae7dfd master -> master

还有身份验证测试工作

$ ssh -T git@github.com
Hi syra37fGIT! You've successfully authenticated, but GitHub does not provide shell access.

鉴于此,当我尝试克隆其他存储库时,出现以下错误消息...

$ git clone git@github.com:syra37fGIT/Angular.git
Cloning into 'Angular'...
\302\226git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

建议的每个提示 https://help.github.com/en/articles/error-permission-denied-publickey很满意(我在 Windows 机器上)。我哪里做错了?

只是一个提示:有可能首先使用 https 克隆了两个存储库中的一个,然后将其转换为 ssh ( FROM HTTPS TO SSH )...我不知道这是否是问题的线索.

更新:正如下面的评论所暗示的,问题在于虽然视觉上 repo 字符串是正确的,但实际发送的字符串是错误的。问题已解决。

最佳答案

作为seen here ,如果该命令是复制粘贴的结果,它可以包含不可见的特殊字符,这将使命令失败。

在这种情况下要做的基本复查是手动再次键入命令,看看问题是否仍然存在。

作为commented here , '\302\226' 是 0xC2 0x96 又名 U+0096 in UTF-8 encoding .
参见 more here :

The original source for this was likely a byte 0x96 in some single-byte 8-bit encoding that has been transcoded incorrectly somewhere along the way. Probably this was originally a Windows CP1252 en dash "", which has byte value 96 in that encoding, which has been translated to UTF-8 as though it was latin-1 (ISO/IEC 8859-1), which is not uncommon.

关于git - 无法使用 ssh 克隆现有存储库,ssh 配置似乎没问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55205613/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com