Uma opção é usar tokens para fornecer a cada usuário um arquivo authorized_keys exclusivo.
De man sshd_config :
AuthorizedKeysFileSpecifies 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).AuthorizedKeysFilemay contain tokens of the form%Twhich are substituted during connection setup. The following tokens are defined:%%is replaced by a literal%,%his replaced by the home directory of the user being authenticated, and%uis replaced by the username of that user. After expansion,AuthorizedKeysFileis taken to be an absolute path or one relative to the user's home directory. Multiple files may be listed, separated by whitespace. Alternately this option may be set tononeto skip checking for user keys in files. The default is.ssh/authorized_keys .ssh/authorized_keys2.
Ênfase minha.
Então você pode definir:
AuthorizedKeysFile .ssh/%u_authorized_keys
Em seguida, para o usuário foo , crie um authorized_keys file .ssh/foo_authorized_keys .
Uma nota sobre permissões
Em man sshd :
~/.ssh/authorized_keys
...
If this file, the~/.sshdirectory, or the user's home directory are writable by other users, then the file could be modified or replaced by unauthorized users. In this case, sshd will not allow it to be used unless theStrictModesoption has been set tono.
Portanto, pode ser necessário colocar as chaves fora de .ssh/ ou definir StrictModes a no . Se você definir StrictModes para no , verifique se outro usuário não pode criar um authorized_keys para outra pessoa ou exclua as chaves autorizadas do outro usuário. Provavelmente melhor fazer algo como:
AuthorizedKeysFile .ssh_%u/authorized_keys
Crie um diretório .ssh_foo/ para o usuário foo , que somente foo pode ler / escrever.
Você pode escolher se deseja também permitir .ssh/authorized_keys usando
AuthorizedKeysFile .ssh/authorized_keys .ssh_%u/authorized_keys
Isso permitirá que a forma "normal" de authorized_keys continue funcionando, e um arquivo authorized_keys deve ser de propriedade do usuário e ter permissões corretas ou será ignorado. Ainda considere que não deve ser possível criar um arquivo authorized_keys para outro usuário, o que poderia significar tocar o arquivo como raiz, de modo que fique vazio.