再次遇到 SSH Server And “Permission denied (publickey)

用这个关键词搜索才找到howtogeek上答案: sshd : Authentication refused: bad ownership or modes for directory /

直接用我文章题目中的搜索,这次不管用。

看log

    $ grep sshd /var/log/audit/audit.log

这个命令很有用。它会告诉你原因。

May 17 16:21:25 localhost sshd[30255]: Authentication refused: bad ownership or modes for directory /home/username

原因很清楚了。是目录权限不对。

方法是:

Fixing Authentication refused: bad ownership or modes for directoryFrom HowToGeekIf you get this error in your logs when trying to setup public key authenticated automatic logins, the problem is a permissions one.You’ll need to perform the following commands
on the user account you are trying to setup:

    chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

http://www.howtogeek.com/wiki/Fixing_Authentication_refused:_bad_ownership_or_modes_for_directory

    chmod go-w ~/  这个很重要。如果你的用户目录被设定为其它用户和组用户可以写,那么即时你更改了 .ssh 目录和其文件也不管用!!!!! 我浪费了多少时间啊。 :( 我做了下面两步,但还是不行。 Permission denied (publickey).

Make sure you do the following:

Make sure the permissions of the .ssh folder are 0700Make sure the permissions of the authorized_keys file are 0600Make sure the user owns the .ssh folder and contents (normally that’s the case but just to make sure)http://blog.artooro.com/2010/02/19/ssh-server-and-permission-denied-publickey/

$ grep sshd /var/log/audit/audit.log

May 17 16:21:25 localhost sshd[30255]: Authentication refused: bad ownership or modes for directory /home/fltrpMay 17 16:21:35 localhost sshd[30257]: Authentication refused: bad ownership or modes for directory /home/fltrphttp://serverfault.com/questions/230771/ssh-configuration-publickeys-permission-denied-publickey-password-error

原文地址:

http://pengyou.rijiben.org/2012/2012-08-29-%E5%86%8D%E6%AC%A1%E9%81%87%E5%88%B0_SSH_Server_And_Permission_denied_publickey.html

public-key生成命令(客户端)

# ssh-keygen -t dsa -f ~/.ssh/id_dsa

# cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

[注释:~/.ssh/id_dsa.pub文件为公钥,拷贝到Server的~/.ssh/目录中,执行cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys,权限只给用户本人,否则无法连接]

允许root直接登录

编辑/etc/ssh/sshd_config, 重新启动sshd

PermitRootLogin yes

ssh localhost “Permission denied (publickey)的更多相关文章

  1. localhost: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

    在开启hadoop时候报错:localhost: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). 此时 ssh ...

  2. github windows配置以及ssh生成 Permission denied (publickey)

    1:进入cmd命令下,或者可以使用GIt工具   (如果出现了 Permission denied 或者配置多个SSH Key跳第6步) git工具  下载地址:https://git-scm.com ...

  3. mac使用ssh出现permission denied(publickey)

    看出错信息是权限太开放的问题,google了一下,修改权限,不只是需要修改 .pem 文件的权限,还需要修改.ssh目录和用户目录 chmod go-w ~/ chmod ~/.ssh chmod ~ ...

  4. ssh 出错 Permission denied (publickey,password).

    将客户端的~/.ssh/know_hosts 文件删掉试试 ssh debug信息 ssh -vvv xxx@192.168.1.111

  5. SSH Key连接github提示Permission denied (publickey).错误

    root@debian64:/home/xiaoliuzi/.ssh/key_backup# ssh -T git@github.com The authenticity of host 'githu ...

  6. ssh 协议执行repo sync 报错:Permission denied (publickey)

    1.ssh key 已经添加ssh key到gerrit服务器,并且执行ssh协议的git clone可以正常克隆代码到本地,可见不是ssh key的问题. 2.manifest清单文件配置 最初在m ...

  7. 由于SSH配置文件的不匹配,导致的Permission denied (publickey)及其解决方法。

    读者如要转载,请标明出处和作者名,谢谢.地址01:http://space.itpub.net/25851087地址02:http://www.cnblogs.com/zjrodger/作者名:zjr ...

  8. SSH方式登录github出现Permission denied (publickey)

    今天在公司上传了代码,回到家pull,结果竟然出现了“Permission denied (publickey)“这种东西.第一反应是key不对,可是上次明明用key登录过,不可能不对啊,难道是文件被 ...

  9. ssh分发秘钥时出现错误“Permission denied (publickey,gssapi-keyex,gssapi-with-mic)”

    因为公司的服务器连接是通过xshell公钥和密码连接的,今天在ssh分发秘钥的时候出现了,下面的错误: [root@iZ2ze97cumk8opqm28h8Z .ssh]# ssh-copy-id - ...

随机推荐

  1. Build Up Your Own Lightweight Workspace

    写一段简单的批处理(.bat)放在自己建的workspace下. @set path=C:/Program Files/Java/jdk1.8.0_101/bin;%PATH%; //jdk的路径 @ ...

  2. lab_c!

    #include<stdio.h> hi() { printf("hello world!\n"); } int main() { hi(); int i = hi() ...

  3. Git学习(1)Git 简介

    Git是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件. Git ...

  4. MonkeyRunner学习(3)脚本编辑

    除了cmd直接操作手机,也可以编辑好脚本后,运行脚本,一次操作多个脚本命令 a) 新建py格式脚本,如iReader.py b) 编辑脚本 #导入模块 from com.android.monkeyr ...

  5. mysql 事件调度器

    1.mysql事件调度器,也就是计划任务,计划做某事,有两种方式: 2.在某个时间点做某事,AT TIMESTAMP [+ INTERVAL INTERVAL] 某个时间点加上偏移. 3.定时地做某事 ...

  6. JavaWeb学习总结(二)—http协议

    http协议概念: * 即超文本传输协议.它规定了浏览器与服务器之间的通讯规则. * http是基于请求/响应模式的,所以分为请求协议和响应协议 http的类型: HTTP协议的版本:HTTP/1.0 ...

  7. ip变更导致连接不到mysql的解决办法

    第一步:ssh连接到服务器 第二步:连接mysql mysql -u root -psqj888 第三步:切换到mysql数据库 use mysql 第四步:查询mysql的user表 SELECT ...

  8. mysql 保留两位小数

    mysql保留字段小数点后两位小数用函数:truncate(s.price,2)即可.如果想用四舍五入的话用round(s.price,2).  

  9. ToolBar Style

    colorPrimaryDark 状态栏背景色. 在 style 的属性中设置. textColorPrimary App bar 上的标题与更多菜单中的文字颜色. 在 style 的属性中设置. A ...

  10. 吐槽下近期的4G手机:

    吐槽下近期的4G手机: 1.iphone6和6p,分别是4.7和5.5吋屏,1810和2915毫安时不可拆卸电池,双核64位苹果A8处理器.电池容量太小,不经用,中度使用一天一充,而且不支持VOOC闪 ...