史萊姆論壇

返回   史萊姆論壇 > 專業主討論區 > 網路疑難應用技術研討區
忘記密碼?
論壇說明

歡迎您來到『史萊姆論壇』 ^___^

您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的!

請點擊這裡:『註冊成為我們的一份子!』

Google 提供的廣告


發文 回覆
 
主題工具 顯示模式
舊 2007-05-03, 11:32 PM   #1
zat5401
註冊會員
榮譽勳章

勳章總數
UID - 267907
在線等級: 級別:2 | 在線時長:18小時 | 升級還需:3小時級別:2 | 在線時長:18小時 | 升級還需:3小時
註冊日期: 2007-05-03
文章: 13
精華: 0
現金: 8 金幣
資產: 8 金幣
預設 疑問 - 關於vsftpd 的設定

local_root 和user_config_dir不會設定,本機使用者無法登入特定資料夾,謝謝。
zat5401 目前離線  
送花文章: 5, 收花文章: 1 篇, 收花: 1 次
回覆時引用此帖
舊 2007-05-04, 04:29 PM   #2 (permalink)
論壇副主管
 
Omar Lin 的頭像
榮譽勳章
UID - 236058
在線等級: 級別:40 | 在線時長:1835小時 | 升級還需:10小時級別:40 | 在線時長:1835小時 | 升級還需:10小時級別:40 | 在線時長:1835小時 | 升級還需:10小時級別:40 | 在線時長:1835小時 | 升級還需:10小時級別:40 | 在線時長:1835小時 | 升級還需:10小時
註冊日期: 2006-04-28
VIP期限: 無限期
文章: 7919
精華: 0
現金: 5759 金幣
資產: 298615 金幣
預設

  local_root=

  定義所有本地用戶的根目錄。當本地用戶登入時,將被更換到此目錄下。默認值為無。

  user_config_dir=

  定義用戶個人配置文件所在的目錄。用戶的個人配置文件為該目錄下的同名文件。個人配置文件的格式與vsftpd.conf格式相同。例如定義 user_config_dir=/etc/vsftpd/userconf,並且主機上有用戶xiaowang,lisi,那我們可以在 user_config_dir的目錄新增名為xiaowang、lisi的兩個文件。當用戶lisi 登入時,VSFTPD則會讀取user_config_dir下lisi這個文件中的設定值,應用於用戶lisi。默認值為無。

這篇應該對您有幫助:
http://163.17.190.135/plog/index.php...00702&blogId=2
__________________
http://e-hom.idv.tw/data/omar/omar-3.gif
Omar Lin 目前離線  
送花文章: 1003, 收花文章: 1547 篇, 收花: 5246 次
回覆時引用此帖
向 Omar Lin 送花的會員:
zat5401 (2007-05-08)
感謝您發表一篇好文章
舊 2007-05-05, 12:53 AM   #3 (permalink)
註冊會員
榮譽勳章

勳章總數
UID - 267907
在線等級: 級別:2 | 在線時長:18小時 | 升級還需:3小時級別:2 | 在線時長:18小時 | 升級還需:3小時
註冊日期: 2007-05-03
文章: 13
精華: 0
現金: 8 金幣
資產: 8 金幣
預設

那個範例並沒有local_root 的選項,如果說有兩個local user 是test1 和test2,那是不是要設兩個?local_root=/etc/home/test1 local_root=/etc/home/test2 或是可以設成 local_root=/etc/home/$user
謝謝
zat5401 目前離線  
送花文章: 5, 收花文章: 1 篇, 收花: 1 次
回覆時引用此帖
舊 2007-05-05, 10:20 AM   #4 (permalink)
管理員
 
Admin1 的頭像
榮譽勳章
UID - 112827
在線等級: 級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時
註冊日期: 2007-02-18
VIP期限: 0000-00
文章: 3507
精華: 0
現金: 1702 金幣
資產: 10196 金幣
預設

引用:
作者: zat5401 查看文章
那個範例並沒有local_root 的選項,如果說有兩個local user 是test1 和test2,那是不是要設兩個?local_root=/etc/home/test1 local_root=/etc/home/test2 或是可以設成 local_root=/etc/home/$user
謝謝

不對,觀念錯誤

local_root 不是這樣子用的

如果你設定 local_root = /home/vsftpd

則 test1 的設定檔為 /home/vsftpd/test1
而 test2 的設定檔為 /home/vsftpd/test2

你想要做的是 virtual user 吧?
你是不是想要給不同的使用者、不同的 chroot directory?
vsftpd 沒辦法直接做到,要做一些額外的設定,例如 BDB(Berkeley db)
不是很難,但也沒有你想像中那麼簡單

請參考 /usr/share/doc/vsfptd-xxx/EXAMPLE

裡面的 VIRTUAL USER 二個小節


引用:
This example shows how to set up vsftpd / PAM with "virtual users".
A virtual user is a user login which does not exist as a real login on the
system. Virtual users can therefore be more secure than real users, beacuse
a compromised account can only use the FTP server.

Virtual users are often used to serve content that should be accessible to
untrusted users, but not generally accessible to the public.

Step 1) Create the virtual users database.
We are going to use pam_userdb to authenticate the virtual users. This needs
a username / password file in "db" format - a common database format.
To create a "db" format file, first create a plain text files with the
usernames and password on alternating lines.
See example file "logins.txt" - this specifies "tom" with password "foo" and
"fred" with password "bar".
Whilst logged in as root, create the actual database file like this:

db_load -T -t hash -f logins.txt /etc/vsftpd_login.db
(Requires the Berkeley db program installed).
NOTE: Many systems have multiple versions of "db" installed, so you may
need to use e.g. db3_load for correct operation. This is known to affect
some Debian systems. The core issue is that pam_userdb expects its login
database to be a specific db version (often db3, whereas db4 may be installed
on your system).

This will create /etc/vsftpd_login.db. Obviously, you may want to make sure
the permissions are restricted:

chmod 600 /etc/vsftpd_login.db

For more information on maintaing your login database, look around for
documentation on "Berkeley DB", e.g.
http://www.sleepycat.com/docs/utility/index.html


Step 2) Create a PAM file which uses your new database.

See the example file vsftpd.pam. It contains two lines:

auth required /lib/security/pam_userdb.so db=/etc/vsftpd_login
account required /lib/security/pam_userdb.so db=/etc/vsftpd_login

This tells PAM to authenticate users using our new database. Copy this PAM
file to the PAM directory - typically /etc/pam.d/

cp vsftpd.pam /etc/pam.d/ftp


Step 3) Set up the location of the files for the virtual users.

useradd -d /home/ftpsite virtual
ls -ld /home/ftpsite
(which should give):
drwx------ 3 virtual virtual 4096 Jul 30 00:39 /home/ftpsite

We have created a user called "virtual" with a home directory "/home/ftpsite".
Let's add some content to this download area:

cp /etc/hosts /home/ftpsite
chown virtual.virtual /home/ftpsite/hosts


Step 4) Create your vsftpd.conf config file.

See the example in this directory. Let's go through it line by line:

anonymous_enable=NO
local_enable=YES

This disables anonymous FTP for security, and enables non-anonymous FTP (which
is what virtual users use).

write_enable=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO

These ensure that for security purposes, no write commands are allowed.

chroot_local_user=YES

This makes sure that the virtual user is restricted to the virtual FTP area
/home/ftpsite we set up above.

guest_enable=YES
guest_username=virtual

The guest_enable is very important - it activates virtual users! And
guest_username says that all virtual users are mapped to the real user
"virtual" that we set up above. This will also determine where on the
filesystem the virtual users end up - the home directory of the user
"virtual", /home/ftpsite.

listen=YES
listen_port=10021

This puts vsftpd in "standalone" mode - i.e. not running from an inetd. This
means you just run the vsftpd executable and it will start up. This also
makes vsftpd listen for FTP requests on the non-standard port of 10021 (FTP
is usually 21).

pasv_min_port=30000
pasv_max_port=30999

These put a port range on passive FTP incoming requests - very useful if
you are configuring a firewall.

Copy the example vsftpd.conf file to /etc:

cp vsftpd.conf /etc/


Step 5) Start up vsftpd.

Go to the directory with the vsftpd binary in it, and:

./vsftpd

If all is well, the command will sit there. If all is not well, you will
likely see some error message.


Step 6) Test.

Launch another shell session (or background vsftpd with CTRL-Z and then "bg").
Here is an example of an FTP session:

ftp localhost 10021
Connected to localhost (127.0.0.1).
220 ready, dude (vsFTPd 1.1.0: beat me, break me)
Name (localhost:chris): tom
331 Please specify the password.
Password:
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/"
ftp> ls
227 Entering Passive Mode (127,0,0,1,117,135)
150 Here comes the directory listing.
226 Transfer done (but failed to open directory).
ftp> size hosts
213 147
ftp>

Comments:
The password we gave was "foo".
Do not be alarmed by the "failed to open directory". That is because the
directory /home/ftpsite is not world readable (we could change this
behaviour if we wanted using anon_world_readable_only=NO but maybe we want
it this way for security.
We can see that we have access to the "hosts" file we copied into the virtual
FTP area, via the size command.



引用:
This example shows how to extend the "VIRTUAL_USERS" example to reflect
a slightly more complex setup.

Let's assume that we want two types of virtual user - one that can only browse
and download content, and another that can upload new content as well as
download existing content.

To achieve this setup, we can use use of vsftpd's powerful per-user
configurability (new in v1.1.0).

In the previous virtual user example, we created two users - tom and fred.
Let's say that we want fred to have write access to upload new files whilst
tom can only download.

Step 1) Activate per-user configurability.

To activate this powerful vsftpd feature, add the following to
/etc/vsftpd.conf:
user_config_dir=/etc/vsftpd_user_conf

And, create this directory:

mkdir /etc/vsftpd_user_conf


Step 2) Give tom the ability to read all files / directories.

At the end of the last example, we noted that the virtual users can only
see world-readable files and directories. We could make the /home/ftpsite
directory world readable, and upload files with world-read permission. But
another way of doing this is giving tom the ability to download files which
are not world-readable.

For the tom user, supply a config setting override for
anon_world_readable_only:

echo "anon_world_readable_only=NO" > /etc/vsftpd_user_conf/tom

Check it out - login as tom and now "ls" will return a directory listing!
Log in as fred and it won't.
NOTE - restart vsftpd to pick up the config setting changes to
/etc/vsftpd.conf. (Advanced users can send SIGHUP to the vsftpd listener
process).


Step 3) Give fred the ability to read all files / directories and create
new ones but not interfere with existing files.

echo "anon_world_readable_only=NO" > /etc/vsftpd_user_conf/fred
echo "write_enable=YES" >> /etc/vsftpd_user_conf/fred
echo "anon_upload_enable=YES" >> /etc/vsftpd_user_conf/fred

Check it out - login as tom and you can't upload. Log in as fred and you can!
Try and delete a file as both tom and fred - you can't.


裡面講得很清楚,按 "文" 施工,保證成功
Admin1 目前離線  
送花文章: 8870, 收花文章: 2195 篇, 收花: 5820 次
回覆時引用此帖
舊 2007-05-05, 07:31 PM   #5 (permalink)
註冊會員
榮譽勳章

勳章總數
UID - 267907
在線等級: 級別:2 | 在線時長:18小時 | 升級還需:3小時級別:2 | 在線時長:18小時 | 升級還需:3小時
註冊日期: 2007-05-03
文章: 13
精華: 0
現金: 8 金幣
資產: 8 金幣
預設

謝謝,雖然多了點,我會仔細研究的,再請問,
則 test1 的設定檔為 /home/vsftpd/test1
而 test2 的設定檔為 /home/vsftpd/test2
這樣是real user或是virtual user?

此帖於 2007-05-07 01:52 PM 被 Admin1 編輯.
zat5401 目前離線  
送花文章: 5, 收花文章: 1 篇, 收花: 1 次
回覆時引用此帖
舊 2007-05-07, 01:52 PM   #6 (permalink)
管理員
 
Admin1 的頭像
榮譽勳章
UID - 112827
在線等級: 級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時級別:29 | 在線時長:972小時 | 升級還需:48小時
註冊日期: 2007-02-18
VIP期限: 0000-00
文章: 3507
精華: 0
現金: 1702 金幣
資產: 10196 金幣
預設

引用:
作者: zat5401 查看文章
謝謝,雖然多了點,我會仔細研究的,再請問,
則 test1 的設定檔為 /home/vsftpd/test1
而 test2 的設定檔為 /home/vsftpd/test2
這樣是real user或是virtual user?

Virtual User ^__^
Admin1 目前離線  
送花文章: 8870, 收花文章: 2195 篇, 收花: 5820 次
回覆時引用此帖
向 Admin1 送花的會員:
zat5401 (2007-05-08)
感謝您發表一篇好文章
發文 回覆



發表規則
不可以發文
不可以回覆主題
不可以上傳附加檔案
不可以編輯您的文章

論壇啟用 BB 語法
論壇啟用 表情符號
論壇啟用 [IMG] 語法
論壇禁用 HTML 語法
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用


所有時間均為台北時間。現在的時間是 11:48 PM


Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2025, Jelsoft Enterprises Ltd.


SEO by vBSEO 3.6.1