ssh-key添加之后依旧需要密码输入Bug的解决
场景重现
要求从10.183.93.181的root用户ssh免密登录至10.110.155.26的boss用户
1.在10.110.155.26 的boss用户下面新建目录.ssh
2.在10.110.155.26 的boss用户下面的.ssh目录中新建文件authorized_keys
3.将10.183.93.181 root用户的公钥放置于authorized_keys中
[boss@10-110-155-26 .ssh]$ cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA7p2wqKGCLASL+EC7vSiqccuofUv6sjXif2P6nXbZnbHZLy6Z3+vAijOvHoqxABg+Hfv5XflRjaO9z8PMwvW3A8ECu+2Y/kYPTMuyC1TG9qYNmyfiVH5jIeKbdyHmtbMl5+R1o1Fbo2FvQYU5qANhjHZqxb1omVXnEJhFLxSzNnwhFgRMNUTcf72Cwqfnn0Sr0ea8A9Eok6XvhQQqk44Pn+VfxIiO6Gngi1JGG3q1BCinaiSqnvSOHj0qjdGZZuXX0/G4AEbWHE7yD4Gf2FwyWTKwLiQzBKPqjTbZVI7XGtekhOv0Fx4tvT2kIdX5DQiABfMyZre9k+dT4M0rvmDJ3Q== root@10-183-93-181
4.在root用户之ssh登录boss@10.110.155.26,发现需要密码
bug调试
使用ssh -vv boss@10.110.155.26,在登录过程的时候发现以下显示
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /root/.ssh/identity ((nil))
debug2: key: /root/.ssh/id_rsa (0x7f42fed4cfe0)
debug2: key: /root/.ssh/id_dsa ((nil))
debug2: key: /root/.ssh/id_ecdsa ((nil))
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
boss@10.110.155.26's password:
ssh -vv没有显示其它异常,只是卡在验证这里
在10.110.155.26上面使用root用户打开sshd的调试模式
[root@10-110-155-26 .ssh]# /usr/sbin/sshd -d -p 4444
debug1: sshd version OpenSSH_5.3p1
debug1: read PEM private key done: type RSA
debug1: private host key: #0 type 1 RSA
debug1: read PEM private key done: type DSA
debug1: private host key: #1 type 2 DSA
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-d'
debug1: rexec_argv[2]='-p'
debug1: rexec_argv[3]='4444'
Set /proc/self/oom_score_adj from 0 to -1000
debug1: Bind to port 4444 on 0.0.0.0.
Server listening on 0.0.0.0 port 4444.
socket: Address family not supported by protocol
然后再次在10.183.93.181上面进行ssh登录。切换至10.110.155.26上面,查看有一条bug记录
Authentication refused: bad ownership or modes for directory /data/slot0/home/boss/.ssh/
也就说明权限异常
1.查看文件权限
[boss@10-110-155-26 .ssh]$ ll -h
-rw-r--r-- 1 boss boss 1.6K Feb 1 15:28 authorized_keys
由于安全原因,authorized_keys权限不能被其它用户所读取,而该文件因为为手动建立,所以权限为644,chmod 600将其权限变更
将authorized_keys改为600权限后,然后发现ssh登录的时候,依然显示的目录权限异常
2.查看文件目录权限
[boss@10-110-155-26 ~]$ ll -d .ssh/
drwxr-xr-x 2 boss boss 99 Feb 1 16:38 .ssh/
将目录权限改为700,再次登陆,发现ssh ok。
总结
因为ssh安全的原因,所以不管是文件,还是目录,很多权限设定为都不能被group和other用户所读取,当权限不满足时,ssh认证会失败,即使ssh-key完全正确
相关权限列表如下:
1.ssh目录之下的各文件的权限
[boss@10-110-155-26 .ssh]$ ll -h
total 20K
-rw------- 1 boss boss 1.6K Feb 1 15:28 authorized_keys
-rw------- 1 boss boss 400 Feb 1 16:38 authorized_keys2
-rw------- 1 boss boss 1.7K Sep 29 17:45 id_rsa
-rw-r--r-- 1 boss boss 400 Sep 29 17:45 id_rsa.pub
-rw-r--r-- 1 boss boss 2.8K Feb 1 15:22 known_hosts
2..ssh目录的权限
[boss@10-110-155-26 ~]$ ll -d .ssh/
drwx------ 2 boss boss 99 Feb 1 16:38 .ssh/
go用户不能对.ssh目录有w权限,设置成755或者700都可以
ssh-key添加之后依旧需要密码输入Bug的解决的更多相关文章
- Linux配置使用SSH Key登录并禁用root密码登录(替换同理)
Linux系统大多说都支持OpenSSH,生成公钥.私钥的最好用ssh-keygen命令,如果用putty自带的PUTTYGEN.EXE生成会不兼容OpenSSH,从而会导致登录时出现server r ...
- Linux配置使用SSH Key登录并禁用root密码登录
Linux系统大多数都支持OpenSSH,生成公钥.私钥的最好用ssh-keygen命令,如果用putty自带的PUTTYGEN.EXE生成会不兼容OpenSSH,从而会导致登录时出现server r ...
- 使用Github SSH Key来避免Hexo部署时输入账户密码
博客原文:http://fengyao.me/2016/04/10/use-git-ssh-key-carry-hexo-deploy/ 前言 当hexo使用https方式连接Github时,每次执行 ...
- github 添加 SSH key
在 github 上添加 SSH key 的步骤: 1.首先需要检查你电脑是否已经有 SSH key 运行 git Bash 客户端,输入如下代码: $ cd ~/.ssh $ ls 这两个命令就是检 ...
- git生成ssh key 避免每次push都要输入账号密码
第一步:生成public/private rsa key pair在命令行中输入ssh-keygen -t rsa -C "your_email@example.com" 默认在这 ...
- github入门:设置添加ssh key<转>
GitHub是个分布式的版本控制库.github通过git使用,可以方便的记录代码版本. 通过github可以学习优秀的代码,可以改进提交其他项目中的bug,借助社区力量促进软件优化完善. 国内外大量 ...
- permission denied (publickey)问题的解决 和 向github添加ssh key
使用ssh key这种方式进行clone ,pull github上面的项目,使用 git clone或者git pull origin master出现permission denied (publ ...
- permission denied (publickey)问题的解决和向github添加ssh key
使用ssh key这种方式进行clone ,pull github上面的项目,使用 git clone或者git pull origin master出现permission denied (publ ...
- (诊断)为GitHub添加SSH key时出现“Could not open a connection to your authentication agent”错误的应对方案(转)
在为windows 环境下的github账户添加SSH key时,需要在Git Bash执行如下命令: 第一步:检查已有的SSH keys $ ls -al ~/.ssh 第二步:生成新的SSH ke ...
随机推荐
- js实现的简单遮罩层
超级简单的一个实现,可能会有局限性,贵在简单易懂,使用的时候执行前loading,执行成功后loaded /* * 显示loading遮罩层 */ function loading() { var m ...
- 77th ploty 制图神器
https://blog.csdn.net/u012897374/article/details/77857980
- github gist 查看html
gist GitHub Gist 指南 https://blog.csdn.net/yz18931904/article/details/80482166 通过修改hosts解决gist.github ...
- i.js
i.js 动态更新 <script type="text/javascript"> function isCardNo(idCard) { // 15位和18位身份证号 ...
- 彻底理解 JS 中 this 的指向
首先必须要说的是,this的指向在函数定义的时候是确定不了的,只有函数执行的时候才能确定this到底指向谁,实际上this的最终指向的是那个调用它的对象(这句话有些问题,后面会解释为什么会有问题,虽然 ...
- paper 142:SDM算法--Supervised Descent Method
对于face recognition的研究,我是认真的(认真expression,哈哈哈~~~~~~)许久没有写blog了,欢迎一起讨论. SDM(Supvised Descent Method)方法 ...
- JavaWeb解决中文乱码
1.Get请求,方案有两种 A:修改Tomcat配置文件 server.xml URIEncoding="UTF-8" 如:<Connector port="8 ...
- dotnet core项目的nuget存储路径
Where's the package location in aspnet core For project.json the nuget directory is in the user prof ...
- div绝对居中、宽高自适应、多栏宽度自适应
<style> body { background-color: #e1ddd9; font-size: 12px; font-family: Verdana, Arial, Helvet ...
- HTML5: HTML5 表单元素
ylbtech-HTML5: HTML5 表单元素 1.返回顶部 1. HTML5 表单元素 HTML5 新的表单元素 HTML5 有以下新的表单元素: <datalist> <ke ...