未配置前
image.png输入
ssh localhost
提示要输入密码。
配置过程
- 生成密钥,生成过程中需要输入的地方,直接 enter
ssh-keygen -t rsa
[root@root .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:KCNz8XfS7n7YnPcodVQkcRLrNsHOeLnErRxy4DasP28 root@vpa-aiui.novalocal
The key's randomart image is:
+---[RSA 2048]----+
| =+o|
| . =.|
| . . + .|
| o . . o B +.|
| o + o S o B &..|
| + o . + o O.=.|
| o+ o+. |
| ...B E. |
| .o..*o..|
+----[SHA256]-----+
执行完后,/root/.ssh/
目录下会生成两文件
- 公钥导入授权文件
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
-
再次尝试登录,成功。
image.png
网友评论