我有以下文件,其中~/.ssh
包含我的公共 SSH 密钥:
- 授权密钥
然后我运行以下命令并添加我的密码,并且没有出现任何错误或警告:
$ ssh-add ~/.ssh/authorized_keys
当我尝试列出我得到的指纹时:
$ ssh-add -l
> The agent has no identities.
当我重新运行ssh-add
并跟进时echo $?
,它会返回一个退出代码,1
表示发生故障。本文档代码 1 表示错误是由以下原因引起的:
Invalid identification string of SSH-protocol
这到底是什么意思?我该如何解决?
答案1
ssh-add
负载私人的钥匙,不是民众键。来自man ssh-add
:
DESCRIPTION
ssh-add adds private key identities to the authentication agent, ssh-agent(1). When run without arguments, it adds
the files ~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and ~/.ssh/identity. After loading a
private key, ssh-add will try to load corresponding certificate information from the filename obtained by appending
-cert.pub to the name of the private key file. Alternative file names can be given on the command line.
尝试不带参数运行它。