使用SSH密钥对GitLab.com进行身份验证时出现问题

使用SSH密钥对GitLab.com进行身份验证时出现问题,ssh,gitlab,Ssh,Gitlab,我刚刚加入gitlab,正式使用GitHub,现在仍然如此。 我在gitlab上创建了一个新项目,我正在尝试推送,但得到一个权限被拒绝(公钥)错误 以下是我系统上ssh文件夹中的文件列表: github_rsa github_rsa.pub 已知的主机 当我检查如何生成ssh密钥时,我在gitlab上看到,首先我应该在命令行中键入%userprofile%\.ssh\id\u rsa.pub,检查我是否有它,然后我准确地键入了%userprofile%\.ssh\id\u rsa.pub,我得到

我刚刚加入gitlab,正式使用GitHub,现在仍然如此。
我在gitlab上创建了一个新项目,我正在尝试推送,但得到一个权限被拒绝(公钥)错误

以下是我系统上ssh文件夹中的文件列表:

  • github_rsa
  • github_rsa.pub
  • 已知的主机
  • 当我检查如何生成ssh密钥时,我在gitlab上看到,首先我应该在命令行中键入
    %userprofile%\.ssh\id\u rsa.pub
    ,检查我是否有它,然后我准确地键入了
    %userprofile%\.ssh\id\u rsa.pub
    ,我得到了这个结果

    C:\Users\slodd' is not recognized as an internal or external command operable program or batch file. 
    
    我不知道我是否键入了错误,因为我实际上只是复制并粘贴在命令行上。

    我以前没有使用过ssh密钥。我使用的是windows 10系统。

    您需要做的是生成一个专用于gitlab服务器的ssh密钥:

    ssh-keygen -t rsa -f "%USERPROFILE%\.ssh\gitlab_rsa" -C "key for GitLab access" -q -P ""
    
    确保您的
    /usr/bin
    文件夹位于
    %PATH%
    中,以便将
    ssh-keygen
    识别为命令

    那么

    #
    # Main gitlab.com server
    #
    Host gitlab.com
    RSAAuthentication yes
    IdentityFile 'C:\Users\slodd\.ssh\gitlab_rsa
    User git