您的位置:首页 > 编程语言 > PHP开发

vsftpd 和Proftp 安装与配置 ZT

2007-11-13 22:56 507 查看

1)安装vsftpd

Ubuntu安装软件倒不是件困难的事,输入:

sudo apt-get install vsftpd

可能会提示你使用光盘,放进去再按回车就行了。

安装了之后会在/home/下建立一个ftp目录。这时候你可以试着访问下ftp://IP地址。应该可以看到一个空白内容的ftp空间。

默认设置下匿名用户可以下载,但不能写入或是上传

2)设置 vsftpd.conf文件

现在我们要让匿名用户无法访问,并且得输入linux上的用户密码后才能访问到他们自己目录里的内容。

首先找到设置vsftpd的文件,位置在/etc/vsftpd.conf

修改之前最好先备份下这个文件:

sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.old

然后可以改动了:

#不让匿名用户使用

#anonymous_enable=YES

#本地用户可用

local_enable=YES

#可用写操作

write_enable=YES

#不需要显示某目录下文件信息

#dirmessage_enable=YES

#加点banner提示

ftpd_banner=Hello~~

#FTP服务器最大承载用户

max_clients=100

#限制每个IP的进程

max_per_ip=5

#最大传输速率(b/s)

local_max_rate=256000

#隐藏帐号

hide_ids=YES

好了,重启下ftp 服务器看看效果

重启后还是和原来一样对吗?呵呵,这是默认的ftp目录在做鬼,我们把它删除,再看看。怎么样?要你输入用户名和密码了吧。

新的问题

1.输入用户名密码后显示的位置是在用户的根目录下,而我们的WEB内容是在public_html目录里

2.用户可以跳到任何其他目录(非常危险..)

要解决这些问题我们还得设置下vsftpd.conf

#启动chroot列表(Change root)

chroot_list_enable=YES

#指定列表位置(我这用的是默认地址)

chroot_list_file=/etc/vsftpd.chroot_list

接下来我们得在vsftpd.chroot_list上写进去我们要限制哪些用户,不让他们“漂移”..

现在有用户linyupark,所以只要sudo nano一下,往里面写就行了

这样我们已经解决第2个问题了,登陆的用户只能在它的用户文件夹里活动,下面我们要更狠一点,让他只能在public_html里活动

依然还是找vsftpd.conf

#这句默认设置里是没有的,自己加

user_config_dir=/etc/自己定义一个设置个别用户用的文件夹地址

根据自己设置的地址,建立一个相应的文件夹,然后往里面建立和用户名相同的文件,nano一下:

#本地用户的根地址,假设用户是linyupark

local_root=/home/linyupark/public_html

好咯,重启下服务器。

=========================================================

1- 使用下面的命令安装proftpd:
Code:
sudo apt-get install proftpd
2- 在etc/shells 加入如下代码 (sudo gedit /etc/shells to open the file)(译注:命令行模式下sudo vi /etc/shells) :
Code:
/bin/false
新建一个 /home/FTP-shared 目录 :
Code:
cd /home
sudo mkdir FTP-shared
创建一个只能用来读取ftp的用户userftp. 这个用户不需要有效的shell(更安全) ,所以选择 /bin/false shell 给 userftp , /home/FTP-shared 作为主目录。
为了是这部分更清楚,我给取此操作的命令行:
Code:
sudo useradd userftp -p your_password -d /home/FTP-shared -s /bin/false
在FTP-shared 目录下新建一个download和一个upload 目录:
Code:
cd /home/FTP-shared/
sudo mkdir download
sudo mkdir upload
现在我们来给它们设置相应的权限:
Code:
cd /home
sudo chmod 755 FTP-shared
cd FTP-shared
sudo chmod 755 download
sudo chmod 777 upload
3- 好了,现在进入proftpd的配置文件:
Code:
sudo gedit /etc/proftpd/proftpd.conf //特别注意路径,网上以前给的是错的
当然你可以按你的需要编辑你自己的proftpd.conf:
Code:
# 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

AllowUser userftp
DenyALL

Umask 022 022
AllowOverwrite off

DenyAll

Umask 022 022
AllowOverwrite off

DenyAll

Umask 022 022
AllowOverwrite on

DenyAll

AllowAll

好了,你已经完成了proftpd的配置,你的服务端口是1980,而读取的参数如下,用户:sauron,密码:你为userftp设置的那个。

4- 启动/停止/重启动你的服务:
Code:
sudo /etc/init.d/proftpd start
sudo /etc/init.d/proftpd stop
sudo /etc/init.d/proftpd restart

对你的proftpd进行一下语法检查:
Code:
sudo proftpd -td5

想知道谁现在连接到你的服务,用ftptop命令(使用字母"t"来转换显示频率),你也可以使用"ftpwho"命令。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: