Ssh

使用無密碼登錄的 Autofs 主目錄

  • September 27, 2016

我想要一個使用者主目錄安裝在登錄(autofs)上的設置。這適用於基於密碼的身份驗證。但是,我想要通過生成公鑰進行無密碼身份驗證。

如果使用者的主目錄儲存在本地(否),則無密碼身份驗證效果很好autofs

在我的情況下,密鑰在遠端伺服器上,並且只有在訪問時才會安裝主目錄,並且伺服器無法驗證您,除非它具有公鑰。

這甚至可能嗎?

(兩台伺服器都在 VirtualBox 上執行 Solaris 10 x86。)

您可以更改AuthorizedKeysFile為主目錄之外的內容,例如/etc/ssh/keys/%u/authorized_keys. 然後密鑰將在/home/%u安裝之前可用。

從手冊頁sshd_config

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''.

引用自:https://unix.stackexchange.com/questions/116531