1系統(tǒng)----系統(tǒng)管理----新立得軟件包管理器----搜索(vsftpd)----勾選vsftpd 安裝
2 終端----sudo gedit /etc/vsftpd.conf 輸入管理密碼 去掉26行(local_enable=yes)29行(write_enable=yes)前的"#"保存
3 運(yùn)行 sudo /etc/init.d/vsftpd restart 重啟服務(wù)
ubuntu下開設(shè)FTP服務(wù)器,vsftpd
地獄使者 發(fā)表于 2007-9-11 16:32:00
apt-get install vsftpd
或者
apt-get install proftpd
或者
apt-get install pureftpd
參考下文:設(shè)置vsftpd
*********************************************************
發(fā)信人: alabaster(春天來了), 信區(qū): Linux
標(biāo) 題: debian做ftp服務(wù)器
發(fā)信站: 瀚海星云 (2006年03月24日15:41:39 星期五), 站內(nèi)信件
修改ip地址
編輯 /etc/network/interfaces 文件,用 sudo vi /etc/network/i
nterfaces,修改 IP 地址。
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
mapping hotplug
script grep
map eth0
# The primary network interface
auto eth0
iface eth0 inet static
address 202.38.??.??
netmask 255.255.255.0
network 202.38.??.??
broadcast 202.38.??.??
gateway 202.38.??.??
編輯 /etc/hosts 這個(gè)文件并且把新IP地址加進(jìn)去,用 sudo vi /etc/hosts
127.0.0.1 localhost.localdomain localhost userftp
202.38.??.?? ???.ustc.edu.cn userftp
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
編輯 /etc/hostname,內(nèi)容改為 ???.ustc.edu.cn
/etc/init.d/networking restart 重新啟動(dòng)網(wǎng)絡(luò)。
安裝 SSH
apt-get install ssh openssh-server
現(xiàn)在可以通過其他電腦
ssh **@202.38.??.??
來遠(yuǎn)程管理服務(wù)器了。
安裝vsftp
apt-get install vsftpd
配置/etc/vsftpd/vsftpd.conf
以下是我的vsftpd.conf內(nèi)容
===============================================================
#服務(wù)器以standalong模式運(yùn)行,這樣可以進(jìn)行下面的控制
listen=YES
#接受匿名用戶
anonymous_enable=YES
#匿名用戶login時(shí)不詢問口令
no_anon_password=YES
# 接受本地用戶
local_enable=YES
# 可以上傳(全局控制).若想要匿名用戶也可上傳則需要設(shè)置anon_upload_enable=YES,
# 若想要匿名用戶可以建立目錄則需要設(shè)置anon_mkdir_write_enable=YES.這里禁止匿
# 名用戶上傳,所以不設(shè)置這兩項(xiàng).
write_enable=YES
#本地用戶上傳文件的umask
local_umask=022
#如果設(shè)為YES,匿名登入者會(huì)被允許上傳目錄的權(quán)限,當(dāng)然,匿名使用者必須要有對(duì)
#上層目錄的寫入權(quán)。
anon_upload_enable=YES
#定義匿名登入的使用者名稱。默認(rèn)值為ftp
ftp_username=ftp
#如果設(shè)為YES,匿名登入者會(huì)被允許新增目錄,當(dāng)然,匿名使用者必須要有對(duì)上層
#目錄的寫入權(quán)。
anon_mkdir_write_enable=YES
# 為YES則進(jìn)入目錄時(shí)顯示此目錄下由message_file選項(xiàng)指定的文本文件(,默認(rèn)為.messa
ge)的內(nèi)容
dirmessage_enable=YES
#本地用戶login后所在目錄,若沒有設(shè)置此項(xiàng),則本地用戶login后將在他的home目錄
#(/etc/passwd的第六個(gè)字段)中.匿名用戶的對(duì)應(yīng)選項(xiàng)是anon_root
#local_root=/home
anon_root=/home/ftp/
# 使用上傳/下載日志,日志文件默認(rèn)為/var/log/vsftpd.log,可以通過xferlog_file選
項(xiàng)修改
xferlog_enable=YES
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#日志使用標(biāo)準(zhǔn)xferlog格式
xferlog_std_format=YES
# You may change the default value for timing out a data connection.
data_connection_timeout=120
# 關(guān)閉本地用戶chroot()
chroot_local_user=NO
#設(shè)置為yes則下面的控制有效。
#開啟要設(shè)置chroot()用戶項(xiàng).
chroot_list_enable=YES
# (default follows)
#指定要設(shè)置chroot()的特定用戶文件
chroot_list_file=/etc/vsftpd.chroot_list
#若設(shè)置為YES則記錄在userlist_file選項(xiàng)指定文件(默認(rèn)是/etc/vsftpd.user_list)中
的用
#戶無法login,并且將檢察下面的userlist_deny選項(xiàng)
userlist_enable=YES
#若為NO,則僅接受記錄在userlist_file選項(xiàng)指定文件(默認(rèn)是/etc/vsftpd.user_list)
中的
#用戶的login請(qǐng)求.若為YES則不接受這些用戶的請(qǐng)求.
userlist_deny=NO
#注意!!!vsftpd還要檢察/etc/vsftpd.ftpusers文件,記錄在這個(gè)文件中的用戶將無法lo
gin!!
#匿名用戶的傳輸比率(b/s)
anon_max_rate=512000
#本地用戶的傳輸比率(b/s)
local_max_rate=1024000
#可接受的最大client數(shù)目
max_clients=100
#每個(gè)ip的最大client數(shù)目
max_per_ip=5
# This option should be the name of a directory which is empty. Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
tcp_wrappers=YES
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/vsftpd.pem
# 每一個(gè)聯(lián)機(jī),都能以獨(dú)立的process 來呈現(xiàn).
setproctitle_enable=YES
#若是啟動(dòng),所有匿名上傳數(shù)據(jù)的擁有者將被更換為chown_username
#當(dāng)中所設(shè)定的使用者。這樣的選項(xiàng)對(duì)于安全及管理,是很有用的。
chown_uploads=YES
#這里可以定義當(dāng)匿名登入者上傳檔案時(shí),該檔案的擁有者將被置換的
#使用者名稱。預(yù)設(shè)值為root。
chown_username=root
====================================================================
增加用戶名一堆(都屬于ftpuser組的)
groupadd ftpuser
mkdir /home/john/
useradd -g ftpuser john
passwd john
更改文件所有者以及權(quán)限
chown -v -R john.ftpuser /home/john/
chmod -v -R 700 /home/john/
給ftpuser組所有用戶共享一個(gè)文件夾,做一個(gè)連接
ln -v -s /home/ftpuser/ /home/john/ftpuser
在每個(gè)用戶的文件夾中設(shè)置.message
做歡迎界面
編輯/etc/vsftpd.user_list
列舉所有的用戶列表。
編輯/etc/vsftpd.chroot_list
填寫不準(zhǔn)進(jìn)入上層目錄的用戶名
給/home/ftp/中允許匿名寫的目錄修改權(quán)限。
chmod -v 777 /home/ftp/temp/
做兩個(gè)定時(shí)工作
crontab -e
在里面寫
0 4 * * 1 rm -rf /home/ftp/incoming/temp/*
# 每星期一凌晨4點(diǎn)清空/home/ftp/incoming/temp/文件夾
0 5 10 * * /sbin/reboot
# 每個(gè)月10日凌晨5點(diǎn)重新啟動(dòng)電腦
如何把用戶限制在家目錄中呢?
我們要自己建一個(gè)文件,在/etc目錄中
#touch /etc/vsftpd.chroot_list
以beinan這個(gè)用戶為例
在vsftpd.chroot_list這個(gè)文件中,把beinan添上去就行。
然后改/etc/vsftpd/vsftpd.conf文件,找如下的兩行
#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd.chroot_list
把前面的#號(hào)去掉,也就是這樣的
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
如果沒有這樣的兩行,就可以自己添加上去也是一樣的。
設(shè)置好后,重新vsFTPD服務(wù)器。
reboot或者重啟vsftpd
好了,ftp服務(wù)器架構(gòu)完成了。
************************************************************************
參考:http://www.ubuntu.ac.cn/wiki
ubuntu下如何利用proftpd構(gòu)架一個(gè)ftp服務(wù)器
1- 使用下面的命令安裝proftpd:
sudo apt-get install proftpd
2- 在etc/shells 加入如下代碼 (sudo gedit /etc/shells to open the file)(譯注:命令行模式下sudo vi /etc/shells) :
/bin/false
新建一個(gè) /home/FTP-shared 目錄 :
cd /home
sudo mkdir FTP-shared
創(chuàng)建一個(gè)只能用來讀取ftp的用戶userftp. 這個(gè)用戶不需要有效的shell(更安全) ,所以選擇 /bin/false shell 給 userftp , /home/FTP-shared 作為主目錄.
為了是這部分更清楚,我給取此操作的命令行:
sudo useradd userftp -p your_password -d /home/FTP-shared -s /bin/false
在FTP-shared 目錄下新建一個(gè)download和一個(gè)upload 目錄:
cd /home/FTP-shared/
sudo mkdir download
sudo mkdir upload
現(xiàn)在我們來給它們?cè)O(shè)置相應(yīng)的權(quán)限:
cd /home
sudo chmod 755 FTP-shared
cd FTP-shared
sudo chmod 755 download
sudo chmod 777 upload
3- 好了,現(xiàn)在進(jìn)入proftpd的配置文件:
sudo gedit /etc/proftpd.conf
當(dāng)然你可以按你的需要編輯你自己的proftpd.conf:
# To really apply changes reload proftpd after modifications.
AllowOverwrite on
AuthAliasOnly on
# Choose here the user alias you want !!!!
UserAlias sauron userftp
ServerName "ChezFrodon"
ServerType standalone
DeferWelcome on
MultilineRFC2228 on
DefaultServer on
ShowSymlinks off
TimeoutNoTransfer 600
TimeoutStalled 100
TimeoutIdle 2200
DisplayFirstChdir .message
ListOptions "-l"
RequireValidShell off
TimeoutLogin 20
RootLogin off
# It's better for debug to create log files ;-)
ExtendedLog /var/log/ftp.log
TransferLog /var/log/xferlog
SystemLog /var/log/syslog.log
#DenyFilter \*.*/
# I don't choose to use /etc/ftpusers file (set inside the users you want to ban, not useful for me)
UseFtpUsers off
# Allow to restart a download
AllowStoreRestart on
# Port 21 is the standard FTP port, so don't use it for security reasons (choose here the port you want)
Port 1980
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd)
MaxInstances 8
# Set the user and group that the server normally runs at.
User nobody
Group nogroup
# Umask 022 is a good standard umask to prevent new files and dirs
# (second parm) from being group and world writable.
Umask 022 022
PersistentPasswd off
MaxClients 8
MaxClientsPerHost 8
MaxClientsPerUser 8
MaxHostsPerUser 8
# Display a message after a successful login
AccessGrantMsg "welcome !!!"
# This message is displayed for each access good or not
ServerIdent on "you're at home"
# Set /home/FTP-shared directory as home directory
DefaultRoot /home/FTP-shared
# Lock all the users in home directory, ***** really important *****
DefaultRoot ~
MaxLoginAttempts 5
#VALID LOGINS
<Limit LOGIN>
AllowUser userftp
DenyALL
</Limit>
<Directory /home/FTP-shared>
Umask 022 022
AllowOverwrite off
<Limit MKD STOR DELE XMKD RNRF RNTO RMD XRMD>
DenyAll
</Limit>
</Directory>
<Directory /home/FTP-shared/download/*>
Umask 022 022
AllowOverwrite off
<Limit MKD STOR DELE XMKD RNEF RNTO RMD XRMD>
DenyAll
</Limit>
</Directory>
<Directory> /home/FTP-shared/upload/>
Umask 022 022
AllowOverwrite on
<Limit READ RMD DELE>
DenyAll
</Limit>
<Limit STOR CWD MKD>
AllowAll
</Limit>
</Directory>
好了,你已經(jīng)完成了proftpd的配置,你的服務(wù)端口是1980,而讀取的參數(shù)如下,用戶:sauron,密碼:你為userftp設(shè)置的那個(gè).
4- 啟動(dòng)/停止/重啟動(dòng)你的服務(wù):
sudo /etc/init.d/proftpd start
sudo /etc/init.d/proftpd stop
sudo /etc/init.d/proftpd restart
對(duì)你的proftpd進(jìn)行一下語法檢查:
sudo proftpd -td5
想知道誰現(xiàn)在連接到你的服務(wù),用ftptop命令(使用字母”t”來轉(zhuǎn)換顯示頻率),你也可以使用”ftpwho”命令
備注:我自己配置的時(shí)候,只是把匿名的取消了,然后把本地用戶打開了,不過,現(xiàn)在我發(fā)現(xiàn)了一個(gè)問題,就是當(dāng)我想把我自己上傳的文件,給另外一個(gè)用戶的時(shí)候,就有點(diǎn)問題了.
聯(lián)系客服