AuthorizedKeysFile line commented out but still seems to work

24,246

That is the default location. You can use AuthorizedKeysFile to change to a different location, but if you don't specify it, then it will look in ~/.ssh/authorized_keys

From the man page (e.g., https://www.freebsd.org/cgi/man.cgi?query=sshd_config&sektion=5):

AuthorizedKeysFile

   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''.
Share:
24,246

Related videos on Youtube

Adam Johns
Author by

Adam Johns

Updated on September 18, 2022

Comments

  • Adam Johns
    Adam Johns over 1 year

    I'm setting up a server on Linode and following their Securing Your Server guide.

    They recommend setting up ssh key pair authentication. I have already uploaded my public key to server and the key pair authentication seems to work fine, but how does it work if the following line is commented out in sshd_config:

    #AuthorizedKeysFile     %h/.ssh/authorized_keys
    
  • dmourati
    dmourati about 9 years
    And further, if you want the key not to work, delete the file, the relevant line, or comment it out.
  • The_Pingu
    The_Pingu over 6 years
    you can also set it to "none" .