AuthorizedKeysFile行已注释掉,但似乎仍然有效


13

我正在Linode上设置服务器,并遵循其“ 保护服务器”指南。

他们建议设置ssh密钥对身份验证。我已经将我的公共密钥上传到服务器,并且密钥对身份验证似乎可以正常工作,但是如果在以下行中注释了以下行,它将如何工作sshd_config

#AuthorizedKeysFile     %h/.ssh/authorized_keys

Answers:


17

这是默认位置。您可以使用AuthorizedKeysFile更改到其他位置,但是如果您不指定它,它将在~/.ssh/authorized_keys

在手册页中(例如https://www.freebsd.org/cgi/man.cgi?query=sshd_config&sektion=5):

授权密钥文件

   Specifies the file that contains the public keys that can be used
   for user authentication.  The format is described in the AUTHO-
   RIZED_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 user-
   name of that user.  After expansion, AuthorizedKeysFile is taken
   to be an absolute path or one relative to the user's home direc-
   tory.  Multiple files may be listed, separated by whitespace.
   The default is ``.ssh/authorized_keys .ssh/authorized_keys2''.

2
此外,如果您希望密钥不起作用,请删除文件,相关行或将其注释掉。
dmourati

1
您也可以将其设置为“ none”。
The_Pingu
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.