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

ssh免密登录

时间:2017-11-15 21:56:09      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:ssh   免密登录   

[root@aniu-saas-1 ~]# ssh-keygen -t rsa -P ‘‘

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): 

Created directory ‘/root/.ssh‘.

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:

c5:76:18:5a:c0:33:b7:8f:03:b9:a2:fe:df:16:50:1a root@aniu-saas-1

The key‘s randomart image is:

+--[ RSA 2048]----+

|       ...o      |

|        E+oo     |

|        .O=..    |

|        =o..     |

|        S+ o     |

|      . . + .    |

|     . .   o     |

|    .    ..      |

|   ........      |

+-----------------+

[root@aniu-saas-1 ~]# touch ~/.ssh/authorized_keys

[root@aniu-saas-1 ~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 

[root@aniu-saas-1 ~]# chmod 600 ~/.ssh/authorized_keys 

[root@aniu-saas-1 ~]# vim /etc/ssh/sshd_config

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile      .ssh/authorized_keys

[root@aniu-saas-1 ~]# systemctl restart sshd

[root@aniu-saas-1 ~]# ssh root@10.26.100.30 ‘cat >> ~/.ssh/authorized_keys‘ < ~/.ssh/id_rsa.pub 

‘cat >> ~/.ssh/authorized_keys‘ < ~/.ssh/id_rsa.pub的作用是,将本地的公钥文件~/.ssh/id_rsa.pub,重定向追加到远程文件authorized_keys。

[root@aniu-saas-1 ~]# ssh root@10.26.100.20 ‘ps ax | grep mysql‘

 3680 ?        Ss     0:00 bash -c ps ax | grep mysql

 3696 ?        S      0:00 grep mysql


ssh免密登录

标签:ssh   免密登录   

原文地址:http://crist.blog.51cto.com/8175849/1982093

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