用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"没有返回任何内容。


当前回答

对于那些最近升级到“现代”ssh版本[OpenSSH_8.1p1, OpenSSL 1.1.1d FIPS 2019年9月10日]-与fedora 31一起提供,似乎不再接受旧的DSA SHA256密钥(我的日期是2006年!)-创建了一个新的rsa密钥,公共添加到授权,客户端私有,一切都完美地工作。

感谢之前的建议,特别是SSH -v非常有用

其他回答

Eval "$(ssh-agent -s)" 首先启动ssh代理

ssh-add ,然后添加ssh密钥

这里工作的是:在客户端上

1) ssh-add

2) ssh-copy-id user@server

密钥已经在一段时间前使用简单的“ssh-keygen -t rsa”创建 我看到了错误消息,因为我没有首先运行ssh-add就将ssh公钥从客户端复制到服务器(使用ssh-id-copy),因为我错误地认为我已经在一段时间之前添加了它们。

注意如何命名ssh密钥文件

如果您有多个密钥对,您可以使用ssh-keygen和-f <密钥名称>来命名输出文件。在我的例子中,我将密钥命名为username@organization和username@organization.pub,这有助于保持多个密钥对的组织。

问题是ssh代理不喜欢@字符。

在我的例子中,这导致了sign_and_send_pubkey: signing failed: agent refused操作错误,并阻止会话密匙环与ssh代理交互。

将密钥文件重命名为username_at_organization解决了这个问题。

正如其他人所提到的,这个错误可能有多种原因。

如果您正在使用SSH with Smart Card (PIV),并将该卡添加到SSH -agent with Ssh-add -s /usr/lib64/pkcs11/opensc-pkcs11.so 你可能会得到错误 Sign_and_send_pubkey:签名失败:代理拒绝操作 如果PIV身份验证已经过期,或者如果您已经移除并重新插入PIV卡,则从ssh登录。

在这种情况下,如果你尝试执行另一个ssh-add -s,你仍然会得到一个错误: 无法添加卡片"/usr/lib64/opensc-pkcs11。所以:代理拒绝操作

根据RedHat Bug 1609055 - pkcs11在代理中的支持是笨拙的,你反而需要做

ssh-add -e /usr/lib64/opensc-pkcs11.so
ssh-add -s /usr/lib64/opensc-pkcs11.so

对我来说,问题在于错误地将公钥复制/粘贴到Gitlab中。复制产生了额外的回报。确保你粘贴的是一行键。