Ubuntu 10.04使用vsftp初级体会

最近在Ubuntu 10.04下玩了几天vsftp,主要目的是实现两台计算机的共享的,samba太老了,现在都不用这个,还是vsftp好,简单又安全,下面记录一下折腾这个的流程,以后再利用vsftp弄个高级点的ftp。以下操作,全是在root下进行。由于我技术有限,此文不是教程,仅作参考。

vsftp就是“非常安全的ftp”。

1.安装

apt-get install vsftpd

为什么会有一个d呢?呵呵,一般来说d表示系统服务进程,所以安装的时候是vsftpd,这个在ssh等等中也是一样的。

2.vsftpd的环境

1} vsftp安装完成后会生成一个名字是ftp的账户,密码ftp,可以在/etc/passwd中看到,一般来说这时候可以建立一个ftp文件,自己设置的是/home/ftp,最好再把ftp改成777的权限。

2} /etc/vsftpd.conf 主要就是vsftpd的配置文件,相当重要的一个东西。

3} /etc/pam.d/vsftpd 与pam组相关的文件,pam组主要用来进行身份认证和抵御功能,初期没必要太了解这个。

4} /etc/ftpusers 这个主要是和上面的搭配,设定拒绝登陆的账号,一般都是本机上的账号,vim它,会发现root在列,这也解释了为啥子我一开始在root下老登陆不进去ftp。

5} finger ftp,这个命令主要是查看ftp这个用户的一些信息,包括登陆时间,默认家目录等等,其中,ftp这个用户的家目录会作为匿名登陆用户显示的目录(即是匿名用户的根目录)。

3.一些重要的概念以及操作

ftp localhost

这个的意思就是,以本地机器连入ftp,就是在你的Ubuntu上连入ftp啦,localhost实际上是指通过lookback接口向应用程序提供连结,localhost的IP是 127.0.0.1,你可以自己看成这个IP就是你自己电脑的IP地址,只不过是专门用来进行系统内部程序的通信用的。

chroot

change root diectry,root指的是根目录,为什么会有这个呢,因为一旦别人连入你的ftp,它可以向上级访问目录,也就是说可以访问你的任何一个文件,这个是不好滴,所以利用chroot可以把连进来的用户限制到一个目录里面操作,它能访问这个文件夹里的一切东西,但是就是不能跳出这个文件夹访问上级目录。这个chroot相当重要。

chown

这个是改变文件的所属用户组的命令,初级阶段不太用的上,以后会说明。

4.自己环境下vsftp的功能,以及配置。下面主要说说自己的配置,顺带说明一些功能。

vsftp的功能:

允许匿名用户登录,登陆的目录为/srv/ftp(也即是我finger ftp得到的ftp用户家目录,这个是vsftp默认的),匿名用户只拥有下载权限,不具备上传,新建文件夹等权限,并且被限制在/srv/ftp目录下,不允许查看上级目录(比如我的/ect /boot等目录)。

允许本地用户登录,本地用户就是指你Ubuntu机器上的用户,比如root,ftp,xxx用户等等,,本地用户拥有所有权限,进入的默认目录是/home/ftp(所以上面说建一个这个目录),并且可以访问机器上的任何目录。

开启FTP的日志功能,记录FTP的所有操作。在vsftpd.conf中很多配置是一环扣一环的,比如说如果write_enable没有开启,那么设置upload=YES也是没有用的。慢慢学习,就会知道一些。

下面是vsftpd.conf的内容。

# 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.### Run standalone? vsftpd can run either from an inetd or as a standalone# daemon started from an initscript.listen=YES #都有注释的,感觉没必要记录,就是让vsftpd以standalone方式启动,一般都如此。## Run standalone with IPv6?# Like the listen parameter, except vsftpd will listen on an IPv6 socket# instead of an IPv4 one. This parameter and the listen parameter are mutually# exclusive.#listen_ipv6=YES## Allow anonymous FTP? (Disabled by default)anonymous_enable=YES #是否允许匿名用户登录## Uncomment this to allow local users to log in.local_enable=YES #是否允许本地用户登录,啥是本地用户?上面有说到了。。。## Uncomment (look up to dictionary) 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 #这个的意思是本地用户上传的文件权限,022=777 077=755。## 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=NO #是否允许匿名用户上传## Uncomment this if you want the anonymous FTP user to be able to create# new directories.anon_mkdir_write_enable=NO #是否允许匿名用户创建文件夹no_anon_password=YES #匿名用户登录时,忽略密码检查## Activate directory messages – messages given to remote users when they# go into a certain directory.dirmessage_enable=YES #显示文件夹信息,即是,一个用户进入某一文件目录时,会显示你事先写好的一些提示信息## If enabled, vsftpd will display directory listings with the time# in your local time zone. The default is to display GMT. The# times returned by the MDTM FTP command are also affected by this# option.use_localtime=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 #指定FTP的数据端口## 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 #所有匿名用户上传的文件的所有者会变成“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.# Note that the default log file location is /var/log/xferlog in this case.#xferlog_std_format=YES #是否使用标准的日志记录文件格式,主要用于一些软件的查看,不用理会## You may change the default value for timing out an idle session.idle_session_timeout=600 #设定空闲连接时间,如果一个连结无操作,600秒后断开## You may change the default value for timing out a data connection.data_connection_timeout=120 #数据连结超时设定,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编码的方式#ascii_download_enable=YES## You may fully customise the login banner string:ftpd_banner=this is wc’s ftp,which has been testing #欢迎信息## 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 restrict local users to their home directories. See the FAQ for# the possible risks in this before using chroot_local_user or# chroot_list_enable below.#chroot_local_user=YES #限制本地用户的目录,我没有使用。## 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 #chroot_local_user为YES的话,那么你开启这个,在下面那个list文件中的用户将不受chroot约束。# (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## Debian customization## Some of vsftpd’s settings don’t fit the Debian filesystem layout by# default. These settings are more Debian-friendly.## 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/empty## This string is the name of the PAM service vsftpd will use.pam_service_name=vsftpd## This option specifies the location of the RSA certificate to use for SSL# encrypted connections.rsa_cert_file=/etc/ssl/private/vsftpd.pemlocal_root=/home/ftp #本地用户登录时候进入的目录max_clients=100 #最多允许的客户端

实际上说vsftp的配置还是比较复杂,而且功能很多,上面也没有一一例举完。

一直有记日记的习惯,可是,旅行回来,都懒得写日记来记录,

Ubuntu 10.04使用vsftp初级体会

相关文章:

你感兴趣的文章:

标签云: