尝试登录时 SSH 私钥失败

尝试登录时 SSH 私钥失败

我的 SSH 出现问题,它不断要求我输入密码和口令。

我首先使用以下方法生成了公钥/私钥对:

$ ssh-keygen -t rsa -C [email protected]

它要求我提供一个文件来保存密钥和然后生成的密码:

$ ssh-keygen -t rsa -C [email protected]
Generating public/private rsa key pair.
Enter file in which to save the key (/home/<USERNAME>/.ssh/id_rsa): SSH_priv_key
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in SSH_priv_key.
Your public key has been saved in SSH_priv_key.pub.
The key fingerprint is:
??:??:??:??:??:??:??:??:??:??:??:??:??:??:??:?? [email protected]

The key's randomart image is:
+---[RSA 2048]----+
.....

然后我登录到另一个 shell 并从第一个 shell 下载私钥并输入:

$ ssh -i ~/.ssh/private-key.txt [email protected]

首先它要求输入密码和密码。我这样做了(告诉自己这可能是正常的,因为这是第一次从这些 shell 登录/到这些 shell)。

然后我注销并尝试再次登录,但它一直要求我输入密码和密码。

所以我读过man ssh-keygen,用谷歌搜索阅读文档/教程,然后将命令更改为:

$ ssh-keygen -trsa -b 2048 -f ~/.ssh/my-server.com

并尝试再次登录但得到相同的结果。

我不知道现在该怎么办?

相关内容