码迷,mamicode.com
首页 > 系统相关 > 详细

Linux sshssh免密码认证

时间:2017-05-16 23:36:20      阅读:288      评论:0      收藏:0      [点我收藏+]

标签:linux   密码   认证   

[root@localhost ~]# ssh-keygen -t rsa #创建密钥对

Generating public/private rsa key pair

Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory ‘/root/.ssh‘.
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:
e0:19:93:d6:0d:fc:3f:7d:fd:b1:67:af:63:bc:d4:67 root@localhost.localdomain
The key‘s randomart image is:
+--[ RSA 2048]----+
|       ..        |
|       o.o       |
|      * ...      |
|     o =  .      |
|      o S  . .  .|
|            o .oo|
|             o..E|
|             .+o=|
|             .o=+|
+-----------------+
[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub root@10.0.0.20 #部署公钥到KVM服务器

The authenticity of host ‘10.0.0.20 (10.0.0.20)‘ can‘t be established.
ECDSA key fingerprint is c3:a2:bc:39:7d:a5:fd:f5:8a:93:28:fd:e6:4c:29:7b.
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@10.0.0.20‘s password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh ‘root@10.0.0.20‘"
and check to make sure that only the key(s) you wanted were added.

[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub root@10.0.0.30 #部署公钥到KVM服务器

The authenticity of host ‘10.0.0.30 (10.0.0.30)‘ can‘t be established.
ECDSA key fingerprint is c3:a2:bc:39:7d:a5:fd:f5:8a:93:28:fd:e6:4c:29:7b.
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@10.0.0.30‘s password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh ‘root@10.0.0.30‘"
and check to make sure that only the key(s) you wanted were added.

[root@localhost ~]#

[root@localhost ~]# ssh 10.0.0.20 #测试登陆服务器
Last login: Tue May 16 22:27:43 2017 from controller

[root@localhost ~]# ssh 10.0.0.30 #测试登陆服务器

Last login: Tue May 16 22:28:11 2017 from controller



本文出自 “gswcfl” 博客,请务必保留此出处http://guoshiwei.blog.51cto.com/2802413/1926443

Linux sshssh免密码认证

标签:linux   密码   认证   

原文地址:http://guoshiwei.blog.51cto.com/2802413/1926443

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!