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


当前回答

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

其他回答

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

ssh-add ,然后添加ssh密钥

对于这个错误:

# git pull
sign_and_send_pubkey: signing failed: agent refused operation
git@github.com: Permission denied (publickey).    
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

在Github帐户>配置文件> ssh中再次验证或添加公钥。

我是这样解决的:

# chmod 400 ~/.ssh/id_rsa

# ls  ~/.ssh/id_rsa -ls  
4 -r--------. 1 reinaldo reinaldo 1679 Jul 26  2017 /home/reinaldo/.ssh/id_rsa

# git pull                                 
remote: Counting objects: 35, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 35 (delta 9), reused 34 (delta 9), pack-reused 0
Unpacking objects: 100% (35/35), done.

谢谢你!

注意如何命名ssh密钥文件

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

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

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

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

在将Fedora 26升级到28之后,我遇到了同样的问题。 下面的日志也不见了

/var/log/secure
/var/log/messages

问题:

antop@localmachine  ~  ssh root@ocp1.example.com
sign_and_send_pubkey: signing failed: agent refused operation
root@ocp1.example.com's password:

错误信息没有指向实际问题。问题由

chmod 700 ~/.ssh
chmod 600 ~/.ssh/*

另一个原因是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