rsaキーを使用するSSHにはパスワードが必要です

rsaキーを使用するSSHにはパスワードが必要です

Ubuntu 14.04 x64オペレーティングシステムを実行しているサーバーがあります。

私のファイルの一部sshd_configフルファイル):

Port 2202
Protocol 2
PermitRootLogin without-password
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      /etc/ssh/keys/%u/authorized_keys
RhostsRSAAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
#PasswordAuthentication yes
UsePAM yes

フォルダ内では、/etc/ssh/keys各システムユーザーには次のファイルを含む独自のフォルダがありますauthorized_keys

ls -l /etc/ssh/keys
drw------- 2 test.com  test.com   4096 Nov 20 06:53 test.com
drw------- 2 root      root       4096 Nov 20 02:29 root

次の Authorized_keys ファイルに対する権限が有効です。

ls -l /etc/ssh/keys/*
/etc/ssh/keys/test.com:
total 4
-r-------- 1 test.com test.com 960 Nov 20 07:17 authorized_keys

/etc/ssh/keys/root:
total 4
-r-------- 1 root root 395 Nov 20 02:29 authorized_keys

ルートとtest.comのAuthorized_keysファイルに同じ公開id_rsaがあります。
SSH経由でrootとしてログインできますが、test.comを使用するとパスワードの入力を求められます。

test.comユーザーに接続しようとしたときのデバッグ情報は次のとおりです。

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/Ivan/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/Ivan/.ssh/id_dsa
debug1: Next authentication method: password

rootとしてログインしようとすると成功します。

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/Ivan/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).

私はたくさんをグーグルしました。私の問題を解決するものが見つかりません。

システムユーザーを生成するコマンドを使用するスクリプトがありますが、デフォルトではuseraddこれらのユーザーにはパスワードはありません。パスワードのないシステムユーザーはsshを介してログインできない可能性があることを知り、test.comユーザーにパスワードを追加しました。役に立たない。

UsePAM yesこれが問題になる可能性があると思います。私はそれをUsePAM no役に立たないように設定しました。

はい、service ssh restartファイルを変更するたびにこれを行いましたsshd_config

私はすべてを試しましたが、今は何も知らないと思います。

どんな助けでも大変感謝します!

ベストアンサー1

私も同じ問題があり、SELinuxが/usr/bin/sshd特定のユーザーにリモートでアクセスしようとしたときに読み取りアクセスをブロックしたことを発見しました。通常は実行/home/できます。

cat /var/log/messages | grep -i ssh

ターゲットサーバー上、エラーを示す行が表示されます。

<Date/Time> <hostname> python: SELinux is preventing /usr/sbin/sshd from read access on the file authorized_keys.#012#012*****  Plugin catchall (100. confidence) suggests   **************************#012#012
If you believe that sshd should be allowed read access on the authorized_keys file by default.#012Then you should report this as a bug.#012
You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# 
ausearch -c 'sshd' --raw | audit2allow -M my-sshd#012# semodule -i my-sshd.pp#012`

SSH接続を許可するようにSELinux権限を編集するか、単にオフ(セキュリティレベルが低い)でこの問題を解決できます。

おすすめ記事