用SSH密钥配置一个新的数字海洋液滴。当我运行ssh-copy-id时,这是我得到的:

ssh-copy-id user@012.345.67.89
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
sign_and_send_pubkey: signing failed: agent refused operation
user@012.345.67.89's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'user@012.345.67.89'"
and check to make sure that only the key(s) you wanted were added.

然而,当我尝试ssh时,会发生这种情况:

ssh user@012.345.67.89
sign_and_send_pubkey: signing failed: agent refused operation
user@012.345.67.89's password: 

输入密码后,我可以正常登录,但这当然违背了创建SSH密钥的初衷。我决定看看ssh-agent服务器端,下面是我得到的:

user@012.345.67.89:~# eval `ssh-agent -s`
Agent pid 5715
user@012.345.67.89:~# ssh-add -l
The agent has no identities.

用户/。Ssh /authorized_keys也包含Ssh -rsa密钥条目,但是find name "keynamehere"没有返回任何内容。


当前回答

我曾经遇到过和你一样的问题,我通过以下步骤解决了它。

Chmod 700 ~/.ssh Chmod 600 ~/.ssh/* ssh-copy-id user@ip ssh-agent - s ssh-add

其他回答

In my case the problem was that GNOME keyring was holding an invalid passphrase for the ssh key to be used. After spending indecent amount of time troubleshooting this issue I ran seahorse and found the entry to hold empty string. I can only guess that it was caused by mistyping the passphrase at first use some time earlier, and then probably cancelling the requester or so in order to fall back to command line. Updating the entry with correct passphrase immediately solved the problem. Deleting that entry (from "login" keyring) and reentering passphrase at that first prompt (and checking the appropriate checkbox) solves this too. Now agent gets the correct passphrase from the unlocked at login keyring named "login" and neither asks for passphrase nor "refuses operation" anymore. Of course YMMV.

这应该是一个超级用户的问题。

对的,我在MacOSX SourceTree中有完全相同的错误,然而,在iTerm2终端中,事情工作得很好。

然而,问题似乎是我有两个ssh代理运行;(

第一个是/usr/bin/ssh-agent(也就是MacOSX的),然后是HomeBrew安装的/usr/local/bin/ssh-agent。

从SourceTree启动一个终端,允许我看到SSH_AUTH_SOCK的差异,使用lsof我找到了两个不同的ssh-代理,然后我能够将密钥(使用ssh-add)加载到系统的默认ssh-代理(即。/usr/bin/ssh-agent), SourceTree恢复正常。

我需要分享,因为我花了太多时间寻找解决方案

这就是解决方案:https://unix.stackexchange.com/a/351742/215375

我正在使用这个命令:

ssh-keygen -o -t rsa -b 4096 -C "email@example.com"

Gnome-keyring不支持生成的密钥。

删除-o参数解决了这个问题。

运行以下命令解决此问题。

这对我很管用。

chmod 600 ~/.ssh/id_rsa

另一个原因是OpenSSH v9.0新默认的NTRU primes + x25519密钥交换,结合gpg-agent(至少在v2.2.32)。

为了解决问题,禁用新的密钥交换算法(因此它的安全效益),如下:

ssh -o 'KexAlgorithm -sntrup761x25519-sha512@openssh.com' [...]

(SSH配置也一样)

参见https://unix.stackexchange.com/questions/701131/use-ntrux25519-key-exchange-with-gpg-agent