deepin配置vsftp(仅配置篇)

来源:互联网 发布:淘宝店铺4钻能卖多少 编辑:程序博客网 时间:2024/05/15 23:48

0、前言:

其实说道配置,很多,我自己也挺迷茫的,因为看起来真的好复杂,我自己是这样配置的,其实/etc/vsftpd.config文件已经有全部说明了,我这里翻译一下,其实配置这个ftp在配置里面去掉注释或者加上注释,又或者改改参数就好了,感觉网上说的大部分都在里面有了,配置文件需要什么就加什么,感觉按这样来就行了,下面我仅仅贴出默认的配置文件加翻译,自己斟酌的修改就好了,其实我这里改了,仅仅本来注释的,而我要的把注释选项去掉了而已。

1、配置:

 可以通过以下三条配置文件来控制用户切换目录。
      chroot_list_enable=YES/NO   #设置是否启用chroot_list_file配置项指定的用户列表文件。
      #如果启动这项功能,则所有列在chroot_list_file之中的使用者不能更改根目录 .默认值为yes。

      chroot_list_file=/etc/vsftpd/chroot_list #指出被锁定在自家目录中的用户的列表文件。

      chroot_list_enable=YES
      通过与chroot_local_user=YES/NO搭配能实现以下几种效果:
      1、当chroot_list_enable=YES,chroot_local_user=YES时,在/etc/vsftpd.chroot_list文件中列出的用户,可以切换到其他目录;未在文件中列出的用户,不能切换到其他目录。
      2、当chroot_list_enable=YES,chroot_local_user=NO时,在/etc/vsftpd.chroot_list文件中列出的用户,不能切换到其他目录;未在文件中列出的用户,可以切换到其他目录。
      3、当chroot_list_enable=NO,chroot_local_user=YES时,所有的用户均不能切换到其他目录。
      4、当chroot_list_enable=NO,chroot_local_user=NO时,所有的用户均可以切换到其他目录。 

------------------------------------------------------听说,这叫华丽的分割线----------------------------------------------------------------------------

# 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).
#允许匿名ftp?(注意-这个默认被加注释)
#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.
#这个不加注释,允许ftp任何方式的写命令
#write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
#默认本地用户为077权限,你也许希望改成022
# if your users expect that (022 is used by most other ftpd's)
#如果想和大多数用户一样使用022
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.
#去掉这个注释可以让匿名ftp用户上传文件,
#这需要上面的写允许被激活(即write_enable=YES没有被注释)
#同时,你需要创建一个可写的文件夹给ftp用户
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#如果你想一个匿名ftp用户可以创建新文件夹可以将这个注释去掉
#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.
#激活uploads/downloads文件夹的日志功能
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
#确保端口传输连接来自于20端口(FTP的数据)。
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!
#如果你想,你可以安排一个特别的用户管理匿名上传的文件。记住!使用root用户上传文件是不推荐的!
#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.
# Note that the default log file location is /var/log/xferlog in this case.
#如果你想的话,你可以让你的日志文件是标准的ftp xferlog格式
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.
#建议你定义一个系统唯一的用户,这样ftp服务器可以使用他作为一个隔离的和特权的用户
#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.
#使这个服务器将识别异步ABOR请求。
#为了安全不推荐(代码是有意义的)。
#不启用他,不管怎样,这也许会拒绝老旧的ftp客户端(连接)
#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模式,但实际上是忽视请求。
#当服务器在ASCII模式,打开下面的选项让服务器真正处理ASCII文件
#值得注意的是,某些ftp服务器的ASCII模式,ASCII支持允许一种服务拒绝攻击(DoS)经过命令“SIZE /big/file”
ascii_upload_enable=YES
ascii_download_enable=YES
#
# You may fully customise the login banner string:
#你可以完全定制登录横幅字符串:
ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#你可以允许一个不允许匿名e-mail地址的文件。
#似乎能有效打击某些DoS攻击
#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().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#你可以指定一个明确的本地用户列表去给chroot函数到达他们的家目录。
#如果chroot_local_user设置为YES,然后这个列表成为用户们不能去使用chroot函数的列表
#(警告!使用chroot会非常危险。如果使用chroot,确保用户在chroot里面不能有写访问去顶层目录
chroot_local_user=YES
chroot_list_enable=NO
# (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.
#你可以激活“-R”选项去内置这个。默认这是禁用的,避免远程用户在大型网站导致过度的I/O。
#不管怎样,一些不友好的FTP客户端,比如“ncftp”和“mirror”假定“-R”选项的存在,所以这是一个暴力的方式去支持他
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
#当监听的指令设为启用时,vsftp运行在standalone模式并且监听在IPv4的套接字。
#这个命令不能与listen_ipv6一起使用
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#这个命令启用在IPv6套接字监听。去监听IPv4和IPv6套接字,你必须用两份配置文件去运行两份vsftp的备份。
#确定这其中一个监听选项被注释
#listen_ipv6=YES

----------------------------------------------------配置翻译完毕.avi-------------------------------------------------------------------------------

按自己需要去搞吧,我很多东西没弄,那些需要配置文件的我都没去配置,额,如果是配置文件的话这个帖子不会说。。。。我不会

2、账户讲解:(仅复制粘贴)

vsftp提供3种远程的登录方式:

(1)匿名登录方式

  就是不需要用户名,密码。就能登录到服务器电脑里面

(2)本地用户方式

  需要帐户名和密码才能登录。而且,这个帐户名和密码,都是在你linux系统里面,已经有的用户。

(3)虚拟用户方式

  同样需要用户名和密码才能登录。但是和上面的区别就是,这个用户名和密码,在你linux系统中是没有的(没有该用户帐号)

3、ftp账户添加:

首先这里需要认识用户和组的概念----我只能说百度吧。

用户:

在/etc/passwd这个文件是密码相关的配置,但不要想歪了,你改不了,讲这个是想说里面可以修改用户默认目录


passwd文件的格式如下:account:password:UID:GID:GECOS:diretory:shell

 account: 用户名或帐号
        password :用户密码占位符
        UID:用户的ID
        GID:用户所在组的ID
        GECOS:用户的详细信息(如姓名,年龄,电话等)
        diretory:用户所的家目录
        shell:用户所在的编程环境
我们这里关注倒数第二个,使用命令cat /etc/passwd |grep ftp可以查看到ftp:x:113:121:ftp daemon,,,:/home/ftp:/bin/false(这是我的,每个人不同,参考就好了)

可以看到我的的一个意思就是用户名为ftp的用户所在家目录为/home/ftp,我们可以改为自己需要的,比如/svr/frp什么的

组:

在/etc/group这个文件记录的是组相关的信息,

group文件的格式如下:group_name:passwd:GID:user_list

第一字段:用户组名称;

第二字段:用户组密码;

第三字段:GID

第四字段:用户列表,每个用户之间用,号分割;本字段可以为空;如果字段为空表示用户组为GID的用户名;

我将这个是要你看看有没这个组而已。。。


用命令cat /etc/group |grep ftp查看有没这个ftp组,我的是这样的ftp:x:121:

可以看到我用cat查看都是存在这样的用户和组而已


创建用户:

用命令useradd -d /home/ftp2 -g ftp ftp2,这个意思是,ftp2的主目录(-d参数)为/home/ftp2(没有这个文件夹请手动创建吧),用户组(-g参数)为ftp

PS:其中自己手动创建的文件主目录,应该设置权限,因为:

为了避免一个安全漏洞,从 vsftpd 2.3.5 开始,chroot 目录必须不可写。使用命令:

 chmod a-w /home/ftp2

这样子,就可以登陆ftp了,登陆的时候实际上进入了/home/ftp2,怎么感觉有点像普通登陆,呵呵了。


ftp登陆记住一点就是文件或者文件夹的权限记住要设置好才是根本!


额,讲着讲着变成讲用户去了,但是,用户是ftp的重要构成,所以还是继续啰嗦吧,上面的useradd是添加本地用户额,就是说,你可以用他来操作系统的,上面用户解释有了,忘了回去看看吧。

下面我们啰嗦一下虚拟用户,想了解还是请看下一篇吧,我发觉又是一大堆东西,感觉踩的坑越来越深了,呵呵呵

参看文章:http://www.cnblogs.com/thinksasa/archive/2013/02/28/2937066.html



0 0