首页 > 代码库 > mac无密登陆到linux
mac无密登陆到linux
最近弄了台linux云服务器,然而每次登陆linux都好麻烦,所以倒腾了下ssh无密登陆。
linux:centos 6.5,自带ssh
mac:yosemite,自带ssh
步骤:
1. 创建key
? .ssh ssh-keygen -t rsaGenerating 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.localThe key‘s randomart image is:+--[ RSA 2048]----+| ooooo=o+ || ...+o= + E || . *.+ . || . =.+ || S=.. || .o || || || |+-----------------+? .ssh lltotal 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.~~:~/.sshroot@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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。