任何原因sshd_config不能设置为不在家中的authorized_keys文件?

SSH和NX故障排除我有一个使用RSA密钥的有效的SSH连接。 麻烦的是,NX服务器希望sshd_config参数AuthorizedKeysFile设置为NX安装文件/var/lib/nxserver/home/.ssh/authorized_keys2 。 一旦我做了这个改变,SSH远程连接就不能被授权。 我试过了,

  • ~/.ssh附加到这个/ var …文件中。
  • 它拥有nx ,组root和644权限,所以我将两个帐户的参数AllowUsersAllowGroups添加到sshd_config的末尾。
  • 每次sshd更改后重新启动SSHD服务器。

不幸的是ssh不会允许这个连接。

 Permission denied (publickey,gssapi-keyex,gssapi-with-mic). 

如果我将sshd_config AuthorizedKeysFile更改回原来的设置,那么它的所有hunky-dorey。 那么,任何原因sshd都不会接受NX想要的授权密钥文件?


这里有一些令人困惑的问题。 拿例如authorized_keys2被折旧 ? 这并不是说这些人关心 ,因为他们在第一篇文章后两年讨论使用authorized_keys2。

许多NX用户注意到,AuthorizedKeysFile只是文件名,而sshd_config上的这个手册页(与CentOS6相同),并说:“[token]扩展之后,AuthorizedKeysFile被视为绝对path或相对于用户的主目录。 “ NXpath应该没问题,对吧?

不幸的是,我的CentOS服务器运行OpenSSH 5.3,因为6.2(在我的客户端)支持AuthorizedKeysFile(s)的空间清单 。

首先,在这种情况下,我总是试着通过开始自定义的未经初始化的sshd来让我的日志达到最大:

 sshd -d -p 11122 -f /new/config/file 

并尝试连接到它:

 ssh -v -p 11122 this.host 

这使您当前的configuration安全,并为您提供有关如何build立连接的所有信息。

现在来一个疯狂的猜测。 sshd将要求密钥文件是:

  1. 服务器可以访问和读取。
  2. 只能由用户写入。 这意味着所有的文件夹(/ var,/ var / lib等) 不应该被login的rootwheel和user之外的任何用户或组写入

这是一个F'd的问题, 因为在使用Kworr的小技巧通过停止守护进程服务并在debugging模式下手动启动它之后,使用Kworr的小技巧来testingsshd ,非主path才能正常工作(这正是“令牌扩展” ) 对不起大家。

因此,回答我自己的问题:不,没有任何理由authorized_keys不能在家外面。

默认是在用户的主目录中使用一个文件(见下文)。 %h可以明确地用来显示。 在这里它显示了每个path由空格分隔的列表…

我会尝试的是将权限更改为600.这就是我所有的帐户我的autorized_keys文件设置。 错误的权限被转换为权限被拒绝错误。 这使您有机会在修复权限之前validation您的authorized_keys文件是否包含不需要的添加项。

如果不同的用户需要使用相同的authorized_keys,那么你有一个问题…

 AuthorizedKeysFile Specifies the file that contains the public keys that can be used for user authentication. The format is described in the AUTHORIZED_KEYS FILE FORMAT section of sshd(8). AuthorizedKeysFile may contain tokens of the form %T which are substituted during connection setup. The following tokens are defined: %% is replaced by a literal '%', %h is replaced by the home directory of the user being authenticated, and %u is replaced by the username of that user. After expansion, AuthorizedKeysFile is taken to be an absolute path or one relative to the user's home directory. Multiple files may be listed, separated by whitespace. The default is “.ssh/authorized_keys .ssh/authorized_keys2”.