私のSSHキーが機能せず、権限が大丈夫に見えます。

私のSSHキーが機能せず、権限が大丈夫に見えます。

私の権限は次のとおりです。

-rw-------.  1 smpadmin staff     400 May 21  2014 id_rsa.pub
-rw-r--r--.  1 smpadmin staff     505 Dec 14 19:19 known_hosts
drwxr-xr-x. 45 smpadmin staff    4096 Jan 20 09:53 ..
-rw-r--r--.  1 smpadmin staff     386 Jan 20 10:32 config
-rwx------.  1 smpadmin staff     400 Jan 20 10:34 authorized_keys
-rwx------.  1 smpadmin staff      400 Jan 20 10:37 authorized_keys2
drwx------.  2 smpadmin staff    4096 Jan 20 10:37 .

丸太:

debug3: record_hostkey: found key type RSA in file /home/alejanpi/.ssh/known_hosts:85
debug3: load_hostkeys: loaded 1 keys from x.x.150.86
debug1: Host 'x.x.150.86' is known and matches the RSA host key.
debug1: Found key in /home/alejanpi/.ssh/known_hosts:85
debug2: bits set: 1525/3072
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/alejanpi/.ssh/id_rsa (0x60005ff50),
debug2: key: /home/alejanpi/.ssh/id_dsa (0x0),
debug2: key: /home/alejanpi/.ssh/id_ecdsa (0x0),
debug2: key: /home/alejanpi/.ssh/id_ed25519 (0x0),
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/alejanpi/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/alejanpi/.ssh/id_dsa
debug3: no such identity: /home/alejanpi/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/alejanpi/.ssh/id_ecdsa
debug3: no such identity: /home/alejanpi/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/alejanpi/.ssh/id_ed25519
debug3: no such identity: /home/alejanpi/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
[email protected]'s password:

両方の承認された鍵ファイルに公開鍵を追加しました。

同じキーが動作する他のサーバーと比較すると、ある時点でそのサーバーのログが表示されます。

Server accepts key: pkalg ssh-rsa blen 277

また、ログのこの部分で別の16進コードを見つけました。

debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/alejanpi/.ssh/id_rsa (0x60006c5f0),

今私のキーが機能していないサーバーの場合、/homeは/にありましたが、別のディスクにマウントしました。 /homeに移動する前は、私の鍵が働いていました。これが私に影響を与えるかどうかはわかりませんが、言及する価値があると思いました。私が家に設置した方法は次のとおりです。

UUID=143f3a8a-55f3-41e4-8797-d1cdb0435c13 /home                   ext4    defaults        0 2

SELinux権限。

drwx------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 .
drwxr-xr-x. smpadmin staff unconfined_u:object_r:user_home_dir_t:s0 ..
-rwx------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 authorized_keys
-rwx------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 authorized_keys2
-rw-r--r--. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 config
-rw-------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 environment
-rw-------. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 id_rsa.pub
-rw-r--r--. smpadmin staff unconfined_u:object_r:ssh_home_t:s0 known_hosts

デフォルトのディレクトリはdrwxr-xr-xです。 root root system_u:object_r:file_t:s0 ホーム

ベストアンサー1

たぶん正しい権限セットを探していないかもしれません。

可能であればSELinuxを一時的に無効にしてみましたか?

サーバーからコンソールにアクセスしようとしています。

# setenforce 0

そしてもう一度接続してみてください。

うまくいけばSELinux関連の問題です。

その後、問題を解決するには正しい権限を取得します。

まず、ファイルのACLを確認してください。

# ls -alZ authorized_keys
-rw-r--r--. root root unconfined_u:object_r:ssh_home_t:s0 authorized_keys

unconfined_u:object_r:ssh_home_t:s0 が表示されない場合は、chcon を使用して権限を変更してください。

# chcon unconfined_u:object_r:ssh_home_t:s0 authorized_keys

おすすめ記事