[root@a1 ~]# ssh-keygen ##生成公私钥匙
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):[enter] ##加密字符保存文件(建议用默认)
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): [enter] ##密钥密码,必须>4个字符,直接回车则没有密码
Enter same passphrase again: [enter] ##确认密码
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:
ab:3c:73:2e:c8:0b:75:c8:39:3a:46:a2:22:34:84:81 root@server0.example.com
The key's randomart image is:
+--[ RSA 2048]----+
|o |
|E. |
|.. |
|. . o |
|.o. * . S |
|oo.o o . |
|+ =. . . |
|o. oo.+.. |
| ..o*. |
+-----------------+ [root@a1 ~]# ls /root/.ssh/id_rsa id_rsa.pub
id_rsa ##私钥,就是钥匙
id_rsa.pub ##公钥,就是锁 添加key认证 ssh-copy-id -i /root/.ssh/id_rsa.pub 加密用户@IP 发钥匙 scp /root/.ssh/id_rsa 用户@IP:/root/.ssh/ **提升安全级别*** 修改openssh-server配置文件 vim /etc/ssh/sshd_config ssh登陆提示修改 vim /etc/motd