我在sshd_config上添加了这些行
AuthorizedKeysCommand /authorizedkeys/authorized-keys
AuthorizedKeysCommandUser ssh-keys
-rwxr-x--- 1 root ssh-keys 712 Dec 23 22:36 /authorizedkeys/authorized-keys
-rwxr-x--- 1 root ssh-keys 712 Dec 23 22:36 authorized-keysssh-键用户可以删除文件(/authorizedkeys/authorizedkeys)。但我不能转到服务器;ssh git@myserver.com
在auth.log中我可以看到这一行,
error: Unsafe AuthorizedKeysCommand: bad ownership or modes for directory /如果我给了770权限/授权密钥/授权密钥文件,我会得到以下错误,
error: Unsafe AuthorizedKeysCommand: bad ownership or modes for file /authorizedkeys/authorized-keys我试着使用根作为AuthorizedKeysCommandUser,并更改了/authorizedkeys/授权-键文件的权限和所有者。它也不管用。
我在ubuntu14.04上使用OpenSSH_6.6.1p1。
注意:我可以很好地处理authorized_keys文件。
发布于 2014-12-24 14:20:46
Unsafe AuthorizedKeysCommand: bad ownership or modes for directory /它在抱怨根目录的所有权或权限。根据文件的源代码,包含文件的目录和所有父目录(包括根目录)都必须由root拥有。所有这些文件和目录的权限必须为0755 (拒绝对组和其他文件的写访问)。
我猜您在根目录上设置了组写权限,或者类似的内容。
将0770权限授予“/authorizedkeys/authorizedkeys”也会导致该文件无法通过权限检查。
为了完整起见,这是发出目录错误的代码部分:
if (stat(buf, &st) < 0 ||
(!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) ||
(st.st_mode & 022) != 0) {
snprintf(err, errlen,
"bad ownership or modes for directory %s", buf);
return -1;
}在以下情况下,它会发出该错误:
发布于 2020-09-03 16:59:11
authorized_keys文件应该是chmod 600,.ssh目录应该是chmod 700。
发布于 2014-12-24 08:19:22
您需要对远程主机上的密钥给予适当的权限:
[remote-host]$ chmod 755 ~/.ssh[remote-host]$ chmod 644 ~/.ssh/authorized_keys
https://stackoverflow.com/questions/27633375
复制相似问题