创建密钥
ssh-keygen -t ecdsa -b 521
一路回车即可
[root@bxy1 ~]# ssh-keygen -t ecdsa -b 521
Generating public/private ecdsa key pair.
Enter file in which to save the key (/root/.ssh/id_ecdsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_ecdsa
Your public key has been saved in /root/.ssh/id_ecdsa.pub
The key fingerprint is:
SHA256:1uCEuKpBzpAxbXCyWfK4Ph2MJJ/7SZ/EukwIljXu208 root@bxy1
The key's randomart image is:
+---[ECDSA 521]---+
|+ o |
| % . . |
|B.+o. . o |
|oB*... o o |
|==o+. S . |
|B.o+.. . |
|.=+oo oE |
| o.=o=.. |
|. .*o+. |
+----[SHA256]-----+
Copy
公钥
ssh-copy-id -i ~/.ssh/id_ecdsa.pub root@<对端IP>
登录对比
未配置
[root@bxy1 ~]# ssh ssh.liumou.site
The authenticity of host 'ssh.liumou.site (106.55.188.168)' can't be established.
ECDSA key fingerprint is SHA256:IrcW68jVTFdtgFJ6alwyatONbWYg+rkdlhKmB7VRxjI.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'ssh.liumou.site,106.55.188.168' (ECDSA) to the list of known hosts.
root@ssh.liumou.site's password:
Linux l 4.19.0-11-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Mar 26 23:52:21 2022 from 116.252.46.164
root@l:~# logout
Connection to ssh.liumou.site closed.
开始配置
[root@bxy1 ~]# ssh-copy-id -i ~/.ssh/id_ecdsa.pub root@ssh.liumou.site
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_ecdsa.pub"
/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
root@ssh.liumou.site's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@ssh.liumou.site'"
and check to make sure that only the key(s) you wanted were added.
免密验证
[root@bxy1 ~]# ssh ssh.liumou.site
Linux l 4.19.0-11-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Mar 26 23:55:57 2022 from 202.103.199.196
root@l:~#
本文来自博客园,作者:坐公交也用券,转载请注明原文链接:https://www.cnblogs.com/liumou-site/articles/16069944.html