LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
12
返回列表 发新帖
楼主: 星煌

为什么ssh的认证key不起作用?

[复制链接]
 楼主| 发表于 2004-3-17 17:29:41 | 显示全部楼层

回复: 我找到ssh key 不起作用的原因啦

最初由 dxzhang 发表
关键是~/.ssh目录的权限有问题
我用的是fedora 1,/etc/bashrc中设置的用户的umask 为002,root的umask 为022,所以,
root自己建立的.ssh目录是755,而普通用户建立的是775,但是ssh 服务要求~/.ssh目录必须只有
用户自己可以写,若组或其他有写权限,则会要求输入密码。
所以,出现了root用户的key起作用,普通用户的key 不起作用。

解决:将~/.ssh目录改为755权限或更严格,ssh的key就起作用了。


原来如此,问题解决,谢谢楼上的兄弟了,没想到这么费解的问题居然出在这么一个小细节上,真是粉有意思~~:cool:
发表于 2004-3-18 11:02:07 | 显示全部楼层
xxx@Monitor/usr/share/doc/ssh# less README.Debian


Problems logging in with RSA authentication:
--------------------------------------------
If you have trouble logging in with RSA authentication then the
problem is probably caused by the fact that you have your home
directory writable by group, as well as user (this is the default on
Debian systems).

Depending upon other settings on your system (i.e. other users being
in your group) this could open a security hole, so you will need to
make your home directory writable only by yourself.  Run this command,
as yourself:

  chmod g-w ~/
发表于 2004-10-22 14:22:28 | 显示全部楼层

我也遇到这种情况

你只要设置
chmod 700 ~/.ssh就ok了。如果~/.ssh所有人能看到的话,就不会起作用的。

我也是搞了一个星期才搞出来的

楼上的那位回答得更经典!
发表于 2004-11-1 20:39:57 | 显示全部楼层
HOST-A (254)
先用ssh-keygen命令 生成rsa类型的的用户key

[root@254 root]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
f2:17:ab:62:c9:33:e1:35:e1:f8:d0:06:7f:e7:aa:9b root@254.localdomain
[root@254 root]#

[root@254 root]# cat ~/.ssh/id_rsa.pub
ssh-rsa XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

以上为你生成的key.将其CP到HOST-B上~/.ssh/authorized_keys内即可

有不明白的地方可以再回帖.
发表于 2005-5-21 09:54:37 | 显示全部楼层
还是没搞定~
回复 支持 反对

使用道具 举报

发表于 2005-5-23 22:15:22 | 显示全部楼层
我的也没搞定。
回复 支持 反对

使用道具 举报

发表于 2005-6-1 14:26:35 | 显示全部楼层
.ssh目录和key文件的权限也是一个问题的
把ssh日志打开看看就知道了
回复 支持 反对

使用道具 举报

发表于 2010-10-1 18:15:26 | 显示全部楼层
执行:
chmod go-w ~/ &&  chmod 700 ~/.ssh  &&  chmod 600 ~/.ssh/authorized_keys

参考: http://sial.org/howto/openssh/publickey-auth/problems/
和   http://lepingbeta.com/archives/729
回复 支持 反对

使用道具 举报

发表于 2010-12-3 18:18:39 | 显示全部楼层
ssh-keygen与gnupg有何关联?
回复 支持 反对

使用道具 举报

发表于 2011-3-10 13:01:35 | 显示全部楼层
Post by 星煌;546223
原来如此,问题解决,谢谢楼上的兄弟了,没想到这么费解的问题居然出在这么一个小细节上,真是粉有意思~~:cool:


这个,.ssh 目录的权限问题是很基本的问题,一般是首要要考虑的。所以大家缺省认为这个问题你一定考虑了,基本都没有考虑过建议这个。

但是说实话,确实有很多情况下解决了 .ssh 目录权限问题还是不能认证的。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表