~/.ssh/
只是sshd
用于查找传入用户的公共密钥的默认位置。您可以sshd
通过修改中的AuthorizedKeysFile
指令 来配置位置和要查找的文件/etc/ssh/sshd_config
。我的当前看起来像:
AuthorizedKeysFile %h/.ssh/authorized_keys
该sshd_config
手册页提供了更多的细节:
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”.
请注意,这sshd
对于用户authorized_key
文件的权限非常重要。如果您进行了设置并遇到登录问题,则需要密切注意日志。
AuthorizedKeysFile
可能会破坏其他所有用户的登录(除非您做其他一些聪明事)。仅使用即可添加最小主目录可能更容易~/.ssh/authorized_keys
。