この手順では、sftp 転送専用に作成された sftponly ディレクトリを構成します。ユーザーは、この転送ディレクトリの外部のどのファイルまたはディレクトリも表示できません。
始める前に
root 役割になる必要があります。詳細は、Oracle Solaris 11.2 でのユーザーとプロセスのセキュリティー保護 の割り当てられている管理権利の使用を参照してください。
# groupadd sftp # useradd -m -G sftp -s /bin/false sftponly # chown root:root /export/home/sftponly # mkdir /export/home/sftponly/WWW # chown sftponly:staff /export/home/sftponly/WWW
この構成で、/export/home/sftonly は、root アカウントのみがアクセスできる chroot ディレクトリです。ユーザーには、sftponly/WWW サブディレクトリへの書き込み権があります。
/etc/ssh/sshd_config ファイル内で sftp subsystem エントリを見つけ、このファイルを次のように変更します。
# pfedit /etc/ssh/sshd_config ... # sftp subsystem #Subsystem sftp /usr/lib/ssh/sftp-server Subsystem sftp internal-sftp ... ## Match Group for Subsystem ## At end of file, to follow all global options Match Group sftp ChrootDirectory %h ForceCommand internal-sftp AllowTcpForwarding no
次の変数を使用して chroot のパスを指定できます。
%h – ホームディレクトリを指定します。
%u – 認証されたユーザーのユーザー名を指定します。
%% – % 記号をエスケープします。
実際の chroot 環境内のファイルは異なる可能性があります。
root@client:~# ssh sftponly@server This service allows sftp connections only. Connection to server closed. No shell access, sftp is enforced. root@client:~# sftp sftponly@server sftp> pwd sftp access granted Remote working directory: /chroot directory looks like root directory sftp> ls WWW local.cshrc local.login local.profile sftp> get local.cshrc Fetching /local.cshrc to local.cshrc /local.cshrc 100% 166 0.2KB/s 00:00user can read contents sftp> put /etc/motd Uploading /etc/motd to /motd Couldn't get handle: Permission denieduser cannot write to / directory sftp> cd WWW sftp> put /etc/motd Uploading /etc/motd to /WWW/motd /etc/motd 100% 118 0.1KB/s 00:00user can write to WWW directory sftp> ls -l -rw-r--r-- 1 101 10 118 Jul 20 09:07 motdsuccessful transfer sftp>