[root@localhost ~]# ssh-keygen -t ecdsa
Generating public/private ecdsa key pair.
Enter file in which to save the key (/root/.ssh/id_ecdsa): //密钥存放目录,默认家目录
Created directory
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:5L7C6hZYwzaDsD0ouZaTAwkvGw2nP3fd12tMS/xCsa0 root@localhost.localdomain
The key
+---[ECDSA 256]---+
| |
|+ . |
|.& o . |
|@ * B o . |
|o*o= + .S. o + |
|o*+ o ... . . B .|
|. oo + . . = = |
| . o . E .|
| oo. .. . . |
+----[SHA256]-----+
[root@localhost ~]# cd /~/.ssh //移动到 用户的 .ssh文件夹下
[root@localhost .ssh]# ssh-copy-id -i /root/.ssh/id_ecdsa.pub root@192.168.84.200 //传输密钥到客户机上
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_ecdsa.pub"
The authenticity of host
ECDSA key fingerprint is SHA256:IDDghOrPUcw1fx9V1UZcKL0I23z6QkZiBOVc4kp4Fgw.
ECDSA key fingerprint is MD5:a5:2e:eb:35:17:25:50:53:27:63:54:7a:da:c8:8d:75.
Are you sure you want to continue connecting (yes/no)? yes
/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@192.168.84.200
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.84.200'"
and check to make sure that only the key(s) you wanted were added.
在客户机上 输入
ssh 需登录机器IP地址
即可免密登录