Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有SSH的Git克隆显示错误权限被拒绝(公钥)_Git_Github_Ssh_Ssh Keys - Fatal编程技术网

带有SSH的Git克隆显示错误权限被拒绝(公钥)

带有SSH的Git克隆显示错误权限被拒绝(公钥),git,github,ssh,ssh-keys,Git,Github,Ssh,Ssh Keys,我试图克隆github存储库,但它给了我这个错误。(我正在Windows上使用cmder bash) 我做错了什么,或者我遗漏了什么?我不明白为什么它不起作用。。。这里是错误 λ git clone git@github.com:squizlabs/PHP_CodeSniffer.git Cloning into 'PHP_CodeSniffer'... git@github.com: Permission denied (publickey). fatal: Could not read fr

我试图克隆github存储库,但它给了我这个错误。(我正在Windows上使用cmder bash)

我做错了什么,或者我遗漏了什么?我不明白为什么它不起作用。。。这里是错误

λ git clone git@github.com:squizlabs/PHP_CodeSniffer.git
Cloning into 'PHP_CodeSniffer'...
git@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.
我也像这样尝试过,但出现了以下错误:

λ git clone ssh://git@github.com:vuejs/vue.git
Cloning into 'vue'...
ssh: Could not resolve hostname github.com:vuejs: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
  • 我生成了一个ssh密钥对
  • 我将其添加到ssh代理中
  • 我将它添加到我的/.ssh/config文件中
  • 我将它添加到Github>SSH和GPG-keys>newssh-Key

  • 我终于找到了问题所在。对于其他遇到此问题的人,我的配置文件中的主机说的是“github”,而不是“github.com”。当我把它改成“github.com”时,它现在可以工作了


    这对我来说仍然很奇怪,因为我认为主机部分只针对别名,也许有人可以进一步解释这一点。

    没错,但您必须实际使用别名。以下内容可能适用于ssh config中的“github”别名:git clonessh://git@github:vuejs/vue.git
    λ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (C:\Users\Martins/.ssh/id_rsa): C:\Users\Martins\.ssh\id_rsa_github
    Your identification has been saved in C:\Users\Martins\.ssh\id_rsa_github.
    Your public key has been saved in C:\Users\Martins\.ssh\id_rsa_github.pub.
    The key fingerprint is: SHA256:Zdkc0cerbea3ofgBLavgOLzfLm5JiFw2hZXQ41C0CY martins@MartinsPC
    
    λ ssh-add C:\Users\Martins\.ssh\id_rsa_github
    Identity added: C:\Users\Martins\.ssh\id_rsa_github (C:\Users\Martins\.ssh\id_rsa_github)
    
    Host github
        HostName github.com
        User git
        IdentityFile C:\Users\Martins\.ssh\id_rsa_github
    
    Title: Martins PC
    Key: ssh-rsa AAAAB3HkbB1yc2EAAADAQBAAABAQxbprOpXw7qD9dnb1PIeo8AZ5YxaTUQ8wjpiBGcvw3WjcXCotBLgSWilahLdPVouGjlAh0xB0YB1g3oMrAqQRHb54CDzWJMUWqatzMwL+xorVqPKuNAGVxWcvgWBooteX7D/XrrW5kjUooBM9ffTO2gpP3WcKBMdtjQDZJB0Ba6W/zNMF+1k2u2kq6m7z9QBspMIMqYJhc4YsmOr96JUTFb2Gn4ekJ5kJqW3L5m0UBzwj6WS0DczcgEKUy5r3fZ7sBHS7vhc3ZnNtpfzSpBbL+j/Mgvz8CC+xDGkjR/J/29m7nL martins@MartinsPC