vsftpd を使用して FTP アクセスを /var/www に限定する

vsftpd を使用して FTP アクセスを /var/www に限定する

私はLinux(rasbian)からFTPサーバーとしてvsftpdを実行しており、rootとしてシステムにログインしました。

それでも/var/wwwだけをロックしたいです。これを行うには、vsftpd confをどのように設定する必要がありますか?

ベストアンサー1

方法1:ユーザーホームディレクトリの変更

次の行があることを確認してください。

chroot_local_user=YES

ユーザーホームディレクトリをに設定します/var/www/。既存のユーザーを変更するには、次を使用できます。

usermod --home /var/www/ username

次に、必要な権限を設定します。/var/www/

方法2:使用user_sub_token

ユーザーのホームディレクトリを変更したくない場合は、次を使用できます。

chroot_local_user=YES
local_root=/ftphome/$USER
user_sub_token=$USER

についてuser_sub_token

テンプレートに基づいて各仮想ユーザーのホームディレクトリを自動的に作成します。たとえば、guest_usernameで指定された実際のユーザーのホームディレクトリが/ ftphome / $ USERで、user_sub_tokenが$ USERに設定されている場合、仮想ユーザーテストにログインすると、彼は最終的に/ディレクトリからchroot()されます。 ftphome/テスト。このオプションは、local_rootにuser_sub_tokenが含まれている場合にも適用されます。

ディレクトリを作成し、権限を設定します。

mkdir -p /ftphome/{test,user1,user2}
chmod 770 -R /ftphome
chown -R ftp. /ftphome
usermod -G ftp test

再起動vsftpdして設定をテストしてください。

成功した出力の例:

[root@mail tmp]# ftp localhost
Connected to mail.linuxian.local.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): test
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> mput vhosts
mput vhosts? 
227 Entering Passive Mode (127,0,0,1,146,41)
150 Ok to send data.
226 File receive OK.
24 bytes sent in 3.3e-05 seconds (7.1e+02 Kbytes/s)
ftp> ls -rlt
227 Entering Passive Mode (127,0,0,1,97,90)
150 Here comes the directory listing.
-rw-r--r--    1 787      787            24 Oct 11 19:57 vhosts
226 Directory send OK.
ftp> 221 Goodbye.

おすすめ記事