SCP / SFTPユーザーをディレクトリに制限する簡単な方法はありますか?私が遭遇したすべての方法では、バイナリをコピーしてchroot刑務所を設定する必要がありますが、それは必要ではないと思います。
承認された回答:
SSHはSFTPユーザーのネイティブなchrootをサポートします。あなたはただ供給する必要があります
ChrootDirectory
sshd構成ファイルで、sshdを再起動します。
sftpを実行しているだけの場合は、それ以上何もする必要はありません。残念ながら、これはscpでは機能しません。インタラクティブシェルの場合、バイナリと/devノードをchrootにコピーする必要があります。
単一のユーザー、testuserの構成例:
Match User testuser
ChrootDirectory /home/testuser
ForceCommand internal-sftp
sshd_configのmanページから、注意すべき点がいくつかあります。
All components of the pathname must be root-owned directories that are not writable by any other user or group. After the chroot, sshd(8) changes the working directory to the user's home directory.
詳細については、mansshd_configでChrootDirectoryを検索してください。