亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問板塊 發(fā)新帖
查看: 2479 | 回復(fù): 3
打印 上一主題 下一主題

[FTP] 求助,vsftp無法添加登錄 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-11-10 14:58 |只看該作者 |倒序?yàn)g覽
系統(tǒng)是freebsd7.0,我按照http://www.cngr.cn/article/60/403/2006/2006071951631.shtml配置以后,登錄提示說用戶密碼錯(cuò)誤,究竟pam要怎么設(shè)置才行阿?另外我參考了http://www.howtoforge.com/virtua ... _postgresql_freebsd,也不行,請(qǐng)各位老大幫幫忙。謝謝~

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2008-11-10 16:35 |只看該作者
vsftpd的虛擬用戶配置:PAM + PgSQL + FreeBSD-4
(1.0beta,歡迎debug,本人也會(huì)隨時(shí)更新)
vsftpd可能是世界上最好的ftpd。它在linux世界非常流行,安全,性能高。
本文的目的是讓PgSQL存儲(chǔ)你的vsftp的虛擬用戶和密碼,通過一個(gè)叫做pam的東東來認(rèn)證。

零、簡(jiǎn)述PAM原理。
如果你已經(jīng)對(duì)pam有所了解,請(qǐng)?zhí)^,我知道的可能還不如你多。你不感興趣也請(qǐng)?zhí)^,因?yàn)椴豢催@個(gè)也可配置。
代碼:

用戶 <-> vsftpd <-> PAM模塊 <-> 用戶和密碼數(shù)據(jù)庫(kù)


vsftpd用了一種很聰明同時(shí)也是unix/linux規(guī)范的方法來認(rèn)證用戶,就是PAM。大家對(duì)于PAM,也許有些陌生,但是一直在用。所謂PAM,英文是:Pluggable Authentication Modules,可拔插認(rèn)證模塊(不知道這樣翻譯對(duì)不對(duì))?匆妏lug這個(gè)關(guān)鍵字,就知道是很靈活的。
現(xiàn)在幾乎所有daemon程序一般都是用PAM來進(jìn)行認(rèn)證的,包括telnet/sshd/imapd,甚至你的login,都是用PAM。在 fbsd 4上的朋友,你可以打ps -ax|grep pam,你會(huì)發(fā)現(xiàn)login了多少個(gè)控制臺(tái),就會(huì)有多少個(gè)寫著pam的進(jìn)程。

PAM的最大好處是靈活。它不管你的用戶和密碼用什么數(shù)據(jù)格式存儲(chǔ)(數(shù)據(jù)庫(kù)也好,通常用的密碼文件也好),只要有相應(yīng)的PAM模塊就可以存儲(chǔ)。比如說,大家不僅可以用vsftpd + PgSQL做用戶登陸驗(yàn)證,只要你喜歡你還可以用MySQL,Oracle,LDAP數(shù)據(jù)庫(kù)存儲(chǔ)用戶數(shù)據(jù),只要有相應(yīng)的PAM就可以。所有的daemon 都可以用一個(gè)后臺(tái)數(shù)據(jù)庫(kù)來做用戶驗(yàn)證登陸,包括telnet/sshd等等。

pam的配置機(jī)制在不同版本的freebsd上有差異。
freebsd-4放在/etc/pam.conf,一個(gè)文件記錄所有pam服務(wù)。
freebsd-5放在/etc/pam.d,/usr/local/etc/pam.d。每個(gè)pam服務(wù)由一個(gè)獨(dú)立的文件記錄。

本文不打算詳細(xì)敘述PAM的配置。PAM的配置不是很難,畢竟,只是要你配置一些參數(shù),不是叫你開發(fā)一個(gè)pam模塊出來。而且本文的篇幅所限,偶剛剛知道的一點(diǎn)東西希望能夠起到拋磚引玉的作用。等偶對(duì)pam再玩得深入和熟一點(diǎn)的時(shí)候,再寫一篇關(guān)于深入一點(diǎn)關(guān)于pam的東東?

準(zhǔn)備開始:提要
簡(jiǎn)單講講要用到的配置文件的作用。
引用:

/etc/pam.conf #pam服務(wù)的配置
/etc/pam_pgsql.conf #pam_pgsql.so的配置
/usr/local/etc/vsftpd.conf #vsftpd的配置



一、安裝vsftpd,PostgreSQL,pam_pgsql。
我都是使用port來安裝的,請(qǐng)大家用port/package來安裝,不要自己下載源碼來編譯,否則可能根據(jù)本文的方法可能無法正常使用。其中vsftpd和pam-pgsql一定要用port/package來安裝。
以下是他們的port目錄:
引用:

/usr/ports/ftp/vsftpd
/usr/ports/databases/postgresql7
/usr/ports/security/pam-pgsql



安裝:只要cd進(jìn)去,然后make install就OK了。

二、PostgreSQL安裝(如果你已經(jīng)有了PostgreSQL,不需要看這一節(jié))
簡(jiǎn)單提提用port來裝PostgreSQL的過程,因?yàn)锽SD版上的裝PgSQL的方法都是自己下載源碼編譯的。我是用port來編譯安裝,因?yàn)檫@是fbsd推薦的安裝方法,而且安裝的軟件會(huì)根據(jù)bsd的hier(目錄結(jié)構(gòu))來安裝,比較便于管理。
當(dāng)用port來安裝好PostgreSQL,默認(rèn)的數(shù)據(jù)庫(kù)管理用戶是pgsql(port里頭的安裝程序自動(dòng)添加的),其他系統(tǒng)默認(rèn)的是postgres。初始化PostgreSQL的程序如下:
1、初始數(shù)據(jù)庫(kù)。請(qǐng)先用root登陸或者su到root。然后,打命令:
代碼:

# su pgsql
# initdb


正常初始化的應(yīng)該有以下提示:
引用:

This database system will be initialized with username "pgsql".
This user will own all the data files and must also own the server process.

Creating directory /usr/local/pgsql/data
Creating directory /usr/local/pgsql/data/base
Creating directory /usr/local/pgsql/data/global
Creating directory /usr/local/pgsql/data/pg_xlog
Creating template1 database in /usr/local/pgsql/data/base/1

[snip]

Success. You can now start the database server using:

/usr/local/bin/postmaster -D /usr/local/pgsql/data
or
/usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start



2、啟動(dòng)PostgreSQL
代碼:

# /usr/local/etc/rc.d/010.pgsql.sh start


更多詳細(xì)的幫助,請(qǐng)看freebsddiary上面的一篇用port來安裝PostgreSQL的文章,全英文。
http://www.freebsddiary.org/postgresql.php

三、設(shè)定用戶數(shù)據(jù)庫(kù)。
我是PgSQL的初學(xué)者,命令行用得不熟,因而要借助phpPgAdmin來管理數(shù)據(jù)庫(kù)。
1、先創(chuàng)建一個(gè)數(shù)據(jù)庫(kù),叫做mydb。
2、建立一個(gè)數(shù)據(jù)表叫做ftp,用來存儲(chǔ)用戶名和帳號(hào)。這個(gè)數(shù)據(jù)表的結(jié)構(gòu)是pam_pgsql模塊規(guī)定的最簡(jiǎn)單的表了,每一個(gè)字段都是必須的,你可以擴(kuò)展這個(gè)表的結(jié)構(gòu),但是不要?jiǎng)h除這些字段。我導(dǎo)出了一個(gè)SQL腳本,方便大家創(chuàng)建。
代碼:

CREATE TABLE "ftp" (
"ID"                int4 DEFAULT nextval('public."ftp_ID_seq"')  NOT NULL ,
"usr"               varchar(32) NOT NULL ,
"pass"              varchar(32) NOT NULL ,
"expired"           bool DEFAULT false  NOT NULL ,
"newtok"            bool DEFAULT false  NOT NULL
);



請(qǐng)創(chuàng)建一些用戶,方便調(diào)試:
這是我的ftp表,這些記錄名字都是隨便起的。但請(qǐng)注意只有expired為f(假)的可以成功登陸。
代碼:

ID |   usr   |  pass   | expired | newtok
----+---------+---------+---------+--------
  1 | ftp     | ftp     | f       | f
  2 | ftp1    | ftp1    | t       | t
  4 | ftp3    | ftp3    | f       | f
  6 | go      | abcdef  | f       | f
  3 | ftp2    | ftp2    | f       | f
  5 | downftp | downftp | f       | f



3、創(chuàng)建一個(gè)pgsql用戶叫做pamusr,密碼也是pamusr。賦予pamusr對(duì)于ftp表的select權(quán)限,注意select就夠了。pam_pgsql只是讀數(shù)據(jù)表,而不是修改它。你也可以用其他用戶,比如管理PgSQL的pgsql/postgres用戶,但是從安全角度著想,建一個(gè)專門提供給pam_pgsql的弱權(quán)限的用戶更好!

備注:
數(shù)據(jù)庫(kù),數(shù)據(jù)表,用戶名都不必跟我一樣,pam_pgsql沒有規(guī)定,但是這些設(shè)定,必須跟pam_pgsql的配置文件/etc/pam_pgsql.conf的一致。

四、設(shè)定pam_pgsql模塊:編輯/etc/pam_pgsql.conf
在/etc/pam.conf里頭加上以上的幾行,更多的資料參考/usr/local/share/doc/pam-pgsql/README
代碼:

#host = 127.0.0.1  這個(gè)不需要,默認(rèn)是本地連接的。如果要連接遠(yuǎn)程服務(wù)器,請(qǐng)?jiān)O(shè)置你的IP,并且去掉#
database = mydb
user = pamusr  #剛才添加的訪問PgSQL的用戶
password = pamusr #訪問PgSQL的密碼
table = ftp
user_column = usr     #用戶名在數(shù)據(jù)表中的字段
pwd_column = pass     #用戶密碼在數(shù)據(jù)表中的字段
expired_column = expired  #用戶是否已經(jīng)過期的字段名
newtok_column = newtok    #用戶是否需要修改密碼的字段



五、設(shè)置pam服務(wù)。在/etc/pam.conf,加入以下幾項(xiàng)
代碼:

# service-name  module-type     control-flag    module-path  argument

vsftpd    auth          required        pam_pgsql.so  #
vsftpd   account        required        pam_pgsql.so #
vsftpd    password      required        pam_pgsql.so#


注意這里的service name為vsftpd,這不是必須的。前提是不要跟pam.conf已經(jīng)有的service name沖突。vsftpd.conf中的pam_service_name一項(xiàng)要跟這里的service name對(duì)應(yīng)。
關(guān)于freebsd-5的PAM的配置
在freebsd-5中的pam配置機(jī)制,跟freebsd-4有不同。你應(yīng)該在/etc/pam.d或者/usr/local/etc/pam.d里頭建立一個(gè)名位vsftpd的文件,內(nèi)容跟上面的內(nèi)容一樣。本人在fbsd 5-current上嘗試過配置,但總不成功,無論是pam_pgsql還是pam_mysql,總是提示說找不到這些pam。google了一下,發(fā)現(xiàn)這個(gè)錯(cuò)誤好像是fbsd 5-current的bug
http://unix.derkeiler.com/Mailin ... t/2003-07/0278.html


六、配置vsftpd。這個(gè)是參考vsftpd虛擬用戶設(shè)置1的官方文檔進(jìn)行配置的
1、用adduser增加一個(gè)用戶,名為virtual。

2、配置/usr/local/etc/vsftpd.conf
代碼:

anonymous_enable=NO
local_enable=YES
write_enable=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
chroot_local_user=YES
guest_enable=YES
dual_log_enable=YES
guest_username=virtual   #我們剛才增加的本地用戶,虛擬用戶將會(huì)享有這個(gè)名為virtual本地用戶的權(quán)限。
pam_service_name=vsftpd  # 這個(gè)就是我在pam.conf里頭設(shè)置的pam服務(wù)的名稱,沒有這一項(xiàng),vsftpd是用名為ftp的pam服務(wù)。
listen=YES
secure_chroot_dir=/usr/local/share/vsftpd/empty   #請(qǐng)加上這一項(xiàng),vsftpd默認(rèn)的secure_chroot_dir是/usr/share/empty,用port安裝的話,不會(huì)自動(dòng)創(chuàng)建這個(gè)目錄,而是放在/usr/local/share/vsftpd/empty。當(dāng)然你也可以自己創(chuàng)建一個(gè)目錄。



七、調(diào)試
用standalone的方法來啟動(dòng)vsftpd,不要用inetd。
代碼:

/usr/local/libexec/vsftpd
或者
/usr/local/libexec/vsftpd 配置文件名(如vsftpd.conf.1, vsftpd.conf.2)
一般他是搜索/usr/local/etc目錄,如果你放在其他地方就要寫上完整的路徑。


如果沒有沒有出什么提示證明vsftpd啟動(dòng)成功。實(shí)踐中,我常常出現(xiàn)的錯(cuò)誤是沒有用root來啟動(dòng)vsftpd,或者chroot路徑不對(duì)。
下面ftp試試
代碼:

> ftp 192.168.1.10
Connected to 192.168.1.10.
220 (vsFTPd 1.2.0)
Name (192.168.1.10:powerplane): downftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.


yeah,成功了。

總結(jié)
想要配置vsftpd + 其他的PAM認(rèn)證方法,本文都可做參考。當(dāng)然,你可能會(huì)修改有關(guān)pam.conf的設(shè)置了。
freebsd的port里頭除了有pam_pgsql的模塊以外,還有pam_mysql,pam_ldap的。
一般都是放在/usr/ports/security

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2008-11-13 11:50 |只看該作者
貼一下你的vsftpd.conf配置文件

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2008-11-13 15:25 |只看該作者
我的配置文件,因?yàn)椴粫?huì)搞所以全加#了
# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
#local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
#write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
#local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
ftpd_banner=Hello I Love You~~~!!!
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES

#anonymous_enable=NO
#local_enable=YES
#write_enable=NO
#anon_upload_enable=NO
#anon_mkdir_write_enable=NO
#anon_other_write_enable=NO
#chroot_local_user=YES
#guest_enable=YES
#dual_log_enable=YES
#guest_username=virtual
pam_service_name=vsftpd
listen=YES
secure_chroot_dir=/usr/local/share/vsftpd/empty
#connect_from_port_20=YES
background=YES
anon_root=/ftp/ftp
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP