Linux

AuthorizedKeysFile 行已註釋掉,但似乎仍然有效

  • August 24, 2017

我正在 Linode 上設置伺服器並遵循他們的保護您的伺服器指南。

他們建議設置 ssh 密鑰對身份驗證。我已經將我的公鑰上傳到伺服器並且密鑰對身份驗證似乎工作正常,但是如果以下行被註釋掉,它是如何工作的sshd_config

#AuthorizedKeysFile     %h/.ssh/authorized_keys

那是預設位置。您可以使用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''.

引用自:https://serverfault.com/questions/691009