权限错误github(无法识别ssh密钥) [英] Permissions error github (ssh key not recognized)

查看:317
本文介绍了权限错误github(无法识别ssh密钥)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从另一个(本地)存储库推送后,我似乎已经失去了对github帐户的权限。我现在收到以下错误:

  git push 
权限被拒绝(publickey).fatal:
远程终端意外挂断

然后我按照以下步骤重新生成密钥:

  ssh-keygen 
使用id_rsa.pub

然而,这是不成功的。当我尝试建议下面的代码时,我收到以下错误:

  ssh-add -l 
无法打开与您的身份验证代理的连接。

有什么想法?

解决方案

第一步:检查SSH密钥

/ p>

  $ cd〜/ .ssh 
#检查用户是否有名为.ssh的目录目录
#如果它显示没有这样的文件或目录,则跳到第3步。否则继续第2步。

第2步:备份和删除现有的SSH密钥

  $ ls 
#列出当前目录中的所有子目录
#config id_rsa id_rsa.pub known_hosts

$ mkdir key_backup
#在当前目录中创建一个名为key_backup的子目录

$ cp id_rsa * key_backup
#将id_rsa密钥对复制到key_backup

$ rm id_rsa *
#删除id_rsa密钥对
code>

第3步:生成一个新的SSH密钥

  $ ssh-keygen -t rsa -Cyour_email@youremail.com
#创建一个新的ssh密钥提供的电子邮件

#生成公钥/私钥rsa密钥对。
#输入要保存密钥的文件(/home/you/.ssh/id_rsa):
#输入密码(空密码):[输入密码]
#输入再次输入相同的密码:[再次输入密码短语]
#您的身份已保存在/home/you/.ssh/id_rsa中。
#您的公钥已保存在/home/you/.ssh/id_rsa.pub。
#关键指纹是:
#01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email @ youremail。第4步:将您的SSH密钥添加到GitHub中

  $ sudo apt-get install xclip 
#下载并安装xclip

$ xclip -sel剪辑< ; 〜/ .ssh / id_rsa.pub
#将id_rsa.pub文件的内容复制到剪贴板

然后,转到hithub,执行以下操作:
$ b $ ol <

  • 转到您的帐户设置

  • 点击左侧栏中的SSH密钥 点击添加SSH密钥
  • >
  • 点击添加密钥

  • 输入您的GitHub密码确认操作

  • 第5步:测试所有内容

      $ ssh -T git @ github。 com 
    #尝试ssh到github

    如果可以,您会看到

     您好用户名!您已成功通过身份验证,但GitHub不
    #提供shell访问权限。

    否则(它发生在我身上),您会看到

     代理承认使用密钥签名失败。 
    #debug1:没有更多的身份验证方法可以尝试。
    #权限被拒绝(publickey)。

    解决这个问题

      $ ssh-add 
    #为/home/you/.ssh/id_rsa输入密码短语:[tippy tap]
    #添加的身份:/home/you/.ssh/id_rsa /home/you/.ssh/id_rsa)

    原始信息



    https://help.github.com/articles/generating- ssh-keys



    https://help.github.com/articles/error-agent-admitted-failure-to-sign


    I seem to have lost my permissions to a github account after pushing to it from another (local) repository. I am now receiving the following error:

    git push 
    Permission denied (publickey).fatal: 
    The remote end hung up unexpectedly
    

    I then took the following steps to regenerate a key:

    ssh-keygen
    Set up an ssh on my account for this laptop, using id_rsa.pub
    

    However, this was unsuccessful. When I try the following code suggested, I receive the following error:

    ssh-add -l
    Could not open a connection to your authentication agent.
    

    Any thoughts?

    解决方案

    I solved this problem following this step-by-step instructions:

    Step 1: Check for SSH keys

    $ cd ~/.ssh
    # Checks to see if there is a directory named ".ssh" in your user directory
    # If it says "No such file or directory" skip to step 3. Otherwise continue to step 2.
    

    Step 2: Backup and remove existing SSH keys

    $ ls
    # Lists all the subdirectories in the current directory
    # config  id_rsa  id_rsa.pub  known_hosts
    
    $ mkdir key_backup
    # Makes a subdirectory called "key_backup" in the current directory
    
    $ cp id_rsa* key_backup
    # Copies the id_rsa keypair into key_backup
    
    $ rm id_rsa*
    # Deletes the id_rsa keypair
    

    Step 3: Generate a new SSH key

    $ ssh-keygen -t rsa -C "your_email@youremail.com"
    # Creates a new ssh key using the provided email
    
    # Generating public/private rsa key pair.
    # Enter file in which to save the key (/home/you/.ssh/id_rsa):    
    # Enter passphrase (empty for no passphrase): [Type a passphrase]
    # Enter same passphrase again: [Type passphrase again]    
    # Your identification has been saved in /home/you/.ssh/id_rsa.
    # Your public key has been saved in /home/you/.ssh/id_rsa.pub.
    # The key fingerprint is:
    # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@youremail.com
    

    Step 4: Add your SSH key to GitHub

    $ sudo apt-get install xclip
    # Downloads and installs xclip
    
    $ xclip -sel clip < ~/.ssh/id_rsa.pub
    # Copies the contents of the id_rsa.pub file to your clipboard
    

    Then, go to hithub, and do:

    1. Go to your Account Settings
    2. Click "SSH Keys" in the left sidebar
    3. Click "Add SSH key"
    4. Paste your key into the "Key" field
    5. Click "Add key"
    6. Confirm the action by entering your GitHub password

    Step 5: Test everything out

    $ ssh -T git@github.com
    # Attempts to ssh to github
    

    If ok, you'll see

    Hi username! You've successfully authenticated, but GitHub does not
    # provide shell access.
    

    Otherwise (it happened with me), you will see

    Agent admitted failure to sign using the key.
    # debug1: No more authentication methods to try.
    # Permission denied (publickey).
    

    To solve this

    $ ssh-add
    # Enter passphrase for /home/you/.ssh/id_rsa: [tippy tap]
    # Identity added: /home/you/.ssh/id_rsa (/home/you/.ssh/id_rsa)
    

    For original info

    https://help.github.com/articles/generating-ssh-keys

    https://help.github.com/articles/error-agent-admitted-failure-to-sign

    这篇关于权限错误github(无法识别ssh密钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆