无法使用 ssh 克隆现有存储库,ssh 配置似乎没问题
Can't clone an existing repository with ssh, and ssh config seems fine
这是我的情况:
我有两个 私有 存储库。
- git@github.com:syra37fGIT/Angular.git
- git@github.com:syra37fGIT/temp.git
目前我通过克隆为其中一个添加了一个遥控器。
$ git remote -v
origin git@github.com:syra37fGIT/temp.git (fetch)
origin git@github.com:syra37fGIT/temp.git (push)
我认为 ssh 配置正确,因为:
我生成了私钥 (id_rsa) 和 public (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
public 密钥已正确设置到我的 github 帐户个人 settings/SSH 和 GPG 密钥
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'...
26git@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, '26
' is 0xC2 0x96
aka 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@github.com:syra37fGIT/Angular.git
- git@github.com:syra37fGIT/temp.git
目前我通过克隆为其中一个添加了一个遥控器。
$ git remote -v
origin git@github.com:syra37fGIT/temp.git (fetch)
origin git@github.com:syra37fGIT/temp.git (push)
我认为 ssh 配置正确,因为:
我生成了私钥 (id_rsa) 和 public (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
public 密钥已正确设置到我的 github 帐户个人 settings/SSH 和 GPG 密钥
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'...
26git@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, '26
' is 0xC2 0x96
aka 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.