码迷,mamicode.com
首页 > 其他好文 > 详细

3步实现ssh面密码登录

时间:2017-11-09 11:24:18      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:10.10   and   ast   机器   zed   with   使用   int   keygen   

1、上次本机的公钥和私钥

[root@vicweb ~]#ssh-keygen -t rsa
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:
24:ef:78:23:bf:51:2f:40:8b:b8:c8:f6:87:34:69:a4 root@vicweb.localdomain
The keys randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|      . o        |
|    .. * .       |
|   o... S .      |
| .E.=. o o .     |
|  +o.oo = . .    |
| . .. .+ o .     |
|    ..  o.       |
+-----------------+

2、查看生产的文件(非必要操作,只是确认一下)

技术分享

 

3、把公钥传输到指定机器,需要免密码ssh登录的机器,使用ssh-copy-id命令

[root@vicweb ~]#ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.10.90.102
The authenticity of host 10.10.90.102 (10.10.90.102) cant be established.
RSA key fingerprint is 05:90:7f:36:f2:c4:55:15:16:2d:27:54:30:67:c7:74.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 10.10.90.102 (RSA) to the list of known hosts.
root@10.10.90.102s password: 
Now try logging into the machine, with "ssh ‘root@10.10.90.102‘", and check in:

  .ssh/authorized_keys

to make sure we havent added extra keys that you werent expecting.

check in到了对方的 authorized_keys文件,对方机器默认是没有这个文件的,会自动生产一个这个文件,并把自己的公钥写到这个文件

 

4、测试登录即可

 

[root@vicweb ~/.ssh]#ssh root@10.10.90.102
Last login: Thu Nov  9 09:24:35 2017 from 10.10.90.1

已实现自动登录,不需要在输入对方root的密码。

 

3步实现ssh面密码登录

标签:10.10   and   ast   机器   zed   with   使用   int   keygen   

原文地址:http://www.cnblogs.com/netsa/p/7807890.html

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