错误描述 sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey)git
当你在 Linux 电脑的终端下面经过 SSH 连接到 coding.net 或 github.com 时,你或许会看到以下代码:github
sign_and_send_pubkey: signing failed: agent refused operation Permission denied (publickey).
此时咱们能够执行以下命令:ubuntu
ssh -T git@git.coding.net
或者:缓存
ssh -vT git@git.coding.net
咱们或许将看到ssh
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to git.coding.net [124.116.152.172] port 22. debug1: Connection established. ...... debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ssh-rsa SHA256:jok3FH7q5LJ6qvE7iPNehBgXRw51ErE77S0Dn+Vg/Ik debug1: Host 'git.coding.net' is known and matches the RSA host key. debug1: Found key in /home/chen/.ssh/known_hosts:1 debug1: rekey after 4294967296 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: rekey after 4294967296 blocks debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/chen/.ssh/id_rsa debug1: Server accepts key: pkalg ssh-rsa blen 279 sign_and_send_pubkey: signing failed: agent refused operation debug1: Trying private key: /home/chen/.ssh/id_dsa debug1: Trying private key: /home/chen/.ssh/id_ecdsa debug1: Trying private key: /home/chen/.ssh/id_ed25519 debug1: No more authentication methods to try. Permission denied (publickey).
解决办法经过 ssh-add.net
eval "$(ssh-agent -s)"
咱们会看到:debug
Agent pid 25534
执行下面代码:code
ssh-add
显示以下即成功:it
Identity added: /home/chen/.ssh/id_rsa (/home/chen/.ssh/id_rsa)
若是你是多个公钥管理,你只需添加相应的文件,好比我在 bitbucket.org 下的公钥为 /home/chen/.ssh/bitbucket.id_rsa.pub 操做以下:io
ssh-add /home/chen/.ssh/bitbucket.id_rsa.pub
ssh-add [-cDdLlXx] [-t life] [file ...] ssh-add -s pkcs11 ssh-add -e pkcs11
-D :删除ssh-agent中的全部密钥;
-d :从ssh-agent中的删除密钥;
-e : pkcs11 :删除 PKCS#11 共享库 pkcs1 提供的钥匙;
-s : pkcs11 :添加 PKCS#11 共享库 pkcs1 提供的钥匙;
-L :显示 ssh-agent 中的公钥;
-l :显示 ssh-agent 中的密钥;
-t : life:对加载的密钥设置超时时间,超时 ssh-agent 将自动卸载密钥;
-X :对 ssh-agent 进行解锁;
-x :对 ssh-agent 进行加锁;
ssh-add /home/chen/.ssh/id_rsa
ssh-add -d /home/chen/.ssh/id_rsa.pub
ssh-add -l
解决以下代码
git pull github master --allow-unrelated-histories
[陆续添加更新中]