ssh免秘钥登录
SSH免秘钥登录
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责
[root@shiyan ~]# ssh-keygen
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:
25:4b:57:51:1a:fc:c8:73:a8:6d:c9:a1:89:4a:29:90 root@shiyan
The key's randomart image is:
+--[ RSA 2048]----+
| .+o. |
| ..o |
| . o o..+ |
| E . = * o |
| . .S. * = |
| . o . + = |
| o . . |
| . |
| |
+-----------------+
[root@shiyan ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.115.81
root@192.168.115.81's password:
Now try logging into the machine, with "ssh '192.168.115.81'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
[root@shiyan ~]# ssh 192.168.115.81
Last login: Sat Sep 30 07:33:13 2017 from 192.168.115.118
[root@smb ~]# ifconfig
...
eth1 Link encap:Ethernet HWaddr 00:0C:29:33:36:3F
inet addr:192.168.115.81 Bcast:192.168.115.255 Mask:255.255.255.0
...