mac无密登陆到linux
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mac无密登陆到linux相关的知识,希望对你有一定的参考价值。
最近弄了台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 [email protected] The key‘s 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 [email protected]19.29.~~:~/.ssh [email protected]119.29.~~‘s password: id_rsa.pub 100% 399 0.4KB/s 00:00
3. linux,公钥内容追加到authorized_keys
[[email protected]]~/.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 [[email protected]]~/.ssh# cat id_rsa.pub >> authorized_keys
4. mac测试
? ~ ssh [email protected]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的主要内容,如果未能解决你的问题,请参考以下文章