sshd_selinux_copy_context: getconが失敗しました。そのファイルやディレクトリはありません(WindowsからchrootアカウントへのSFTP)。

sshd_selinux_copy_context: getconが失敗しました。そのファイルやディレクトリはありません(WindowsからchrootアカウントへのSFTP)。

ある大学でSFTPクライアントとSSHパスワードなしのログインを使用して、WindowsからRHEL7サーバーにSFTPを試しています。 ユーザーアカウントは根を引いたサーバーから。

openssh バージョンは6.6.1RHEL7 サーバーにインストールされます。

/var/log/secureSFTP接続の試行が失敗した後にサーバーを確認し、次のことがわかりました。

Sep 12 17:00:22 serverbox sshd[32652]: Accepted publickey for specialuser from 1.1.1.77 port 58776 ssh2: RSA FINGERPRINT
Sep 12 17:00:22 serverbox sshd[32652]: pam_unix(sshd:session): session opened for user specialuser by (uid=0)
Sep 12 17:00:22 serverbox sshd[32652]: sshd_selinux_copy_context: getcon failed with No such file or directory [postauth]
Sep 12 17:01:18 serverbox sshd[32652]: Received disconnect from 1.1.1.77: 11: disconnected by user [postauth]
Sep 12 17:01:18 serverbox sshd[32652]: pam_unix(sshd:session): session closed for user specialuser

Putty SFTP または Filezilla (両方ともローカル秘密鍵を使用するように構成されています) から接続しようとすると、同じエラーが発生します。

読みやすくするために、getcon行は次のようになります。

sshd_selinux_copy_context: getcon failed with No such file or directory [postauth]

したがって、公開鍵が承認され、Putty(およびFilezilla SFTP)は、目的のものが見つからなかった後に公開鍵を失います。

権限:

drwxr-xr-x. root root /home/specialuser
drwx------. specialuser sftponly   /home/specialuser/.ssh
drw-------. specialuser sftponly   /home/specialuser/.ssh/authorized_keys

サーバーの有効な公開鍵:

[user@server]# ssh-keygen -l -f authorized_keys
2048 sha1:fi:ng:er:pr:in:tt  rsa-key-20160913 (RSA)

残りのchroot設定については、以下を確認してください。この回答別の質問に投稿しました。

chroot アカウントを使用する SFTP は Linux クライアントで正常に動作します。

私のローカルLinuxシステム(Ubuntu)で同じユーザーアカウントを作成し、specialuserローカルアカウントをid_rsa.pubサーバー上にコピーした後、/home/specialuser/.ssh/authorized_keys問題なくSFTPを使用できました。

SELinuxは除外されます。

トラブルシューティングを支援するためにSELinuxを一時的に無効にしましたが、Windows / Puttyで試しても「getcon failed ...」と同じエラーが表示され続けます。

パスワード確認が有効になっていても同じ問題が発生します。

また、一時的にPasswordAuthenticationを有効にしましたが、specialuserこれはまだサーバーファイルで上記の「getcon failed」エラーでPuttyを終了しました/var/log/secure

この試みを記録するためのデータ(詳細):

Sep 14 10:34:32 serverbox sshd[41228]: Accepted password for specialuser from 1.1.1.77 port 61135 ssh2
Sep 14 10:34:32 serverbox sshd[41228]: pam_unix(sshd:session): session opened for user specialuser by (uid=0)
Sep 14 10:34:32 serverbox sshd[41228]: User child is on pid 41283
Sep 14 10:34:32 serverbox sshd[41228]: Changed root directory to "/home/specialuser" [postauth]
Sep 14 10:34:32 serverbox sshd[41228]: sshd_selinux_copy_context: getcon failed with No such file or directory [postauth]
Sep 14 10:34:32 serverbox sshd[41228]: Starting session: forced-command (config) 'internal-sftp' for specialuser from 1.1.1.77 port 61135 [postauth]
Sep 14 10:34:32 serverbox sshd[41228]: Connection closed by 1.1.1.77 [postauth]
Sep 14 10:34:32 serverbox sshd[41228]: Transferred: sent 1976, received 1728 bytes [postauth]
Sep 14 10:34:32 serverbox sshd[41228]: Closing connection to 1.1.1.77 port 61135 [postauth]
Sep 14 10:34:32 serverbox sshd[41228]: pam_unix(sshd:session): session closed for user specialuser

編集する

サーバーにchroot以外の別のユーザーを作成しました。公開/秘密鍵を介してPuttyサーバーに使用できますPutty SFTPSSH/SFTP

問題は到達chrootのホームフォルダ

付録1:履歴データLogLevel DEBUG3

https://justpaste.it/ycdi (出力がこの質問で許可されている最大文字数を超えています。)

sshd_config

Subsystem sftp internal-sftp #added
Match group sftponly
        PasswordAuthentication yes
        ChrootDirectory %h
        AllowTcpForwarding no
        ForceCommand internal-sftp

ベストアンサー1

おすすめ記事