非標準位置の認証キー

非標準位置の認証キー

認証キーは通常、HOMEディレクトリの.sshの下にあります。

のように非標準的な場所に置きたいです。/etc/AK/authorized_keys.archemar

一致ルールを使用してsshd_configを設定しました。

Match user archemar
        ChrootDirectory /exploit/X25
        AuthorizedKeysFile /etc/AK/authorized_keys.%u
        PasswordAuthentication no
        ForceCommand internal-sftp -u 0002
        PubkeyAuthentication yes

ただし、パスワードなしでログインできず、sshdはエラーを報告します。

sshd[] Failed publickey for archemar from ... port 41154 ssh2: RSA SHA256:...

コマンドはsftp次のいずれかです。ssh

sftp -i archemar archemar@localhost
ssh -i archemar -l archemar localhost

Authorized_keysが一般的な場所にある場合、公開鍵は正しく機能します。

ファイル承認は

-rw-r--r-- 1 root root  802 Oct 24 10:51 authorized_keys.archemar

ディレクトリ/etc/AKdrwx------

私は何を見逃していますか?これはchroot問題ですか?


  • オペレーティングシステムはSuse 12.4であり、
  • セクションを最後に入れてsshd_config再起動しましたが、
  • selinuxが無効になっています。

ベストアンサー1

sshdが課す権限の期待に従う必要があります。

  • 公開鍵を持つディレクトリは、少なくとも誰でも実行できる必要があります。

    chmod 711 /etc/AK
    chown root:root /etc/AK
    
  • 公開鍵はそのユーザーが所有する必要があり、次の権限が私にとって効果的でした。

    chown archemar:root /etc/AK/authorized_keys.archemar
    chmod 640 /etc/AK/authorized_keys.archemar
    

おすすめ記事