文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档> 简单介绍一下linux下的ftp服务及相关配置

简单介绍一下linux下的ftp服务及相关配置

时间:2009-07-04  来源:sjhf

简单介绍一下linux下的ftp服务及相关配置 实验目的搭建一个可以实现上传下载的简易的ftp服务器, 实验环境 vmware 6.5.2+redhatEnterprise linux5 AS 简单了解一下ftp服务器 简单的说 ,我们说支持ftp协议的服务器就是ftp服务器 他的主要功能就是实现文件的上传和下载,通常下载要多一点,在同一个Internet 下的不同操作系统之间实现文件的交流 windows 下利用IIS可以简单的实现ftp服务,利用 Serv-U等第三方工具,也是可以很好的实现ftp服务的 首先我们要明确一点,这个是连接到互联网的,提供一些资料供大家下载的,当然也可以上传,那么他的安全性就显得尤为重要,这也是为什么介绍linux下的ftp服务的原因 常用的服务器端软件,早期的wuftp ,传说中非常安全的vsftp ,以及专业版的proftp 今天的客户端windows server2003 上安装的flashfxp ftp使用的端口 这么说感觉有点乱, 边做边讲吧,,本文不涉及深刻的原理性的东西 我的内核版本 [root@localhost ~]# cd /mnt [root@localhost mnt]# ls cdrom hgfs [root@localhost mnt]# mount /dev/cdrom /mnt/cdrom mount: block device /dev/cdrom is write-protected, mounting read-only [root@localhost mnt]# pwd /mnt [root@localhost mnt]# cd cdrom/Server [root@localhost Server]# [root@localhost Server]# rpm -ivh vsftpd-2.0.5-10.el5.i386.rpm warning: vsftpd-2.0.5-10.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:vsftpd ########################################### [100%] [root@localhost Server]# 安装ftp服务我们只需要一个包rpm -ivh vsftpd-2.0.5-10.el5.i386.rpm 他的登陆用户 普通用户 (系统用户) 匿名用户 (anonymous) 普通用户大都是在系统内建立的账户,或者属于哪个组,访问需要密码 匿名用户 用户名通常是anonymous密码通常为空,也就是说可以允许很多人访问, 他的相关文件 /etc/vsftpd/vsftpd.conf 配置文件 /etc/vsftpd/ftpusers 用户访问控制文件 /etc/vsftpd/user_list 任何情况下写进/etc/vsftpd/ftpusers里的用户都将被禁止访问 修改了/etc/vsftpd/vsftpd.conf 配置文件的关键字后,只有写入/etc/vsftpd/user_list 的用户名,才可以访问 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— # Example config file /etc/vsftpd/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 这里是说目录默认权限, 文件的默认权限是666的话那么666-022=644 目录的默认权限是777的话那么777-022=755 这里你把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 连接端口 20 # # 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 使用标准的xferlog模式 # # 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 是否允许运行特殊的ftp命令async # # 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 使用ASCII的上传和下载 # # 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. #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 若是启动此功能,则允许登入者使用ls -R 这个指令。默认值为NO # # 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. listen=YES # # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6 # sockets, you must run two copies of vsftpd whith two configuration files. # Make sure, that one of the listen options is commented !! #listen_ipv6=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES —————————————————————————————————————————————————————————————————————————————— 我们暂时先不做任何修改 确保我们的DNS解析正常 重启服务 [root@localhost Server]# service vsftpd restart 关闭 vsftpd: [失败] 为 vsftpd 启动 vsftpd: [确定] [root@localhost Server]# 服务器的ip是192.168.0.5 客户端用windows server2003 我用aa用户密码为空登陆ftp服务器ls后显示有一个pub目录 上面装了 flashfxp客户端我们打开FlashFxp 我们双击上层目录,就会发现,它是可以打开得,也是可以下载的, 用记事本打开 虽然这不能看到密码,但这也是很不安全的,想想看我们的ftp服务器是要放到公网上去的,所以我们自身的安全就显得尤为重要, 如果用户用匿名登陆不用填写用户名直接勾选复选款即可 还有就是 注意这里的 用户名是anonymous 密码是空 [root@localhost ~]# vi /etc/vsftpd/vsftpd.conf 我们来修改一下配置文件解决这个问题 chroot_local_user=YES 添加这么一句 注意大小写 保存退出 重启服务 [root@localhost ~]# service vsftpd restart 关闭 vsftpd: [确定] 为 vsftpd 启动 vsftpd: [确定] [root@localhost ~]# 这时不论你是用的匿名用户还是普通用户,都不能对上层目录进行访问,添加的这一句就是把用户限定在,只能访问自己家目录下的文件, 第二个应用 限定特定用户访问, 记得这两个用户控制文件 /etc/vsftpd/ftpusers 把aa用户加入到这个文件之后,会发现aa就访问不了了 /etc/vsftpd/user_list 还有一种方法是 修改配置文件 [root@localhost ~]# vi /etc/vsftpd/vsftpd.conf userlist_enable=YES userlist_deny=NO userlist_file=/etc/vsftpd/user_list 这三句话的意思是,只有写入/etc/vsftpd/user_list 的文件中的用户才可以访问其他用户不允许访问 修改完配置文件后重启服务 [root@localhost ~]# vi /etc/vsftpd/user_list 在这个文件里添加用户 比如说添加了aa bb anonymous 三个用户 这时bb成功登陆 匿名用户成功登陆 aa用户是登陆不上去的 我们说 不论在什么情况下,只要把用户名写入/etc/vsftpd/ftpusers文件的用户就永远登不上去 第三个应用 匿名用户的访问控制 对于匿名用户我们主要是控制他上传,修改,因为你不能确定他上传的东西是不是病毒等等 在修改配置文件之前匿名用户拥有的权限很小,不能建立目录,不能改名,不能上传等等 修改配置文件加入以下几行 位置随便你 [root@localhost ~]# vi /etc/vsftpd/vsftpd.conf anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES [root@localhost ~]# service vsftpd restart 关闭 vsftpd: [确定] 为 vsftpd 启动 vsftpd: [确定] [root@localhost ~]# 重启服务 这时你要是用匿名用户访问的话还是建立不了目录的 因为默认的根目录是不能上传的 [root@localhost ~]# cd /var/ftp [root@localhost ftp]# ls pub [root@localhost ftp]# cd pub [root@localhost pub]# ls [root@localhost pub]# mkdir test [root@localhost pub]# ll 总计 8 drwxr-xr-x 2 root root 4096 05-02 15:24 test [root@localhost pub]# chown ftp test [root@localhost pub]# 我们在匿名用户的默认家目录/var/ftp/pub下建立子目录、 并修改test的属组 这时你在test下就可以建立目录删除 改名上传等等了 [root@localhost pub]# cd test [root@localhost test]# ls aa ad [root@localhost test]# cd aa [root@localhost aa]# ls passwd [root@localhost aa]# 服务器上看一下 实例应用 限制匿名用户的访问数量 修改配置文件 添加如下键值 anon_max_rate=300 限制用户上限为300数字根据实际情况定义 现就简单的介绍到这里,ftp的服务和功能远远不止这些,相对于samba来说,ftp主要是应用于公网。 文中不到或是错误之处,还望看到的朋友多多指教

http://yuzeying.blog.51cto.com/644976/154729

相关阅读 更多 +
排行榜 更多 +
罗马战争与防御

罗马战争与防御

策略塔防 下载
3d坦克突击最新版

3d坦克突击最新版

飞行射击 下载
3d子弹先生射击模拟器安卓版

3d子弹先生射击模拟器安卓版

飞行射击 下载