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

mac无密登陆到linux

时间:2016-10-06 14:43:24      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

最近弄了台linux云服务器,然而每次登陆linux都好麻烦,所以倒腾了下ssh无密登陆。

linux:centos 6.5,自带ssh

mac:yosemite,自带ssh

 

步骤:

1. 创建key

?  .ssh ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/yinkw/.ssh/id_rsa):        <--直接回车
Enter passphrase (empty for no passphrase):                            <--直接回车
Enter same passphrase again: 
Your identification has been saved in /Users/yinkw/.ssh/id_rsa.
Your public key has been saved in /Users/yinkw/.ssh/id_rsa.pub.
The key fingerprint is:
07:20:96:中间这一段藏起来:d1 yinkw@yinkw.local
The keys randomart image is:
+--[ RSA 2048]----+
|    ooooo=o+     |
|   ...+o= + E    |
|     . *.+ .     |
|      . =.+      |
|        S=..     |
|         .o      |
|                 |
|                 |
|                 |
+-----------------+
?  .ssh ll
total 16
-rw-------  1 yinkw  staff   1.6K 10  6 12:11 id_rsa           <--私钥
-rw-r--r--  1 yinkw  staff   399B 10  6 12:11 id_rsa.pub       <--公钥

2. 拷贝公钥到linux

?  .ssh scp id_rsa.pub root@19.29.~~:~/.ssh
root@119.29.~~s password: 
id_rsa.pub                                                                                   100%  399     0.4KB/s   00:00

3. linux,公钥内容追加到authorized_keys

[root@centos]~/.ssh# ll
总用量 4
-rw-r--r-- 1 root root   0 9月  15 00:27 authorized_keys
-rw-r--r-- 1 root root 399 10月  6 12:26 id_rsa.pub
[root@centos]~/.ssh# cat id_rsa.pub >> authorized_keys

4. mac测试

?  ~ ssh root@119.29.~~                                                      
Last login: Thu Oct  6 12:06:38 2016 from 101.106.~~

诶诶,这是怎么回事,没用重启sshd服务,却已经可以使用rsakey登陆了

 

5. linux关闭passwd登陆

/etc/ssh/sshd_config:

PermitEmptyPasswords no

关掉passwd登陆后自我感觉安全多了

 

--done--

 

mac无密登陆到linux

标签:

原文地址:http://www.cnblogs.com/yinkw/p/5933690.html

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