当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

《Linux操作系统》课程教学资源(讲义)第八章 提供Internet服务(8-4)FTP服务器的设置

资源类别:文库,文档格式:DOC,文档页数:4,文件大小:114.5KB,团购合买
FTP 协议定义了一个在远程计算机系统和本地计算机系统之间传输文件的一个标准。 FTP 位于 OSI 参考模型的应用层,并利用 TCP 协议在不同主机间提供可靠的数据传输服务。
点击下载完整版文档(DOC)

841FTP概述 FTP协议定义了一个在远程计算机系统和本地计算机系统之间传输文件的一个标准 FTP位于OSI参考模型的应用层,并利用TCP协议在不同主机间提供可靠的数据传输服务 842实例一设置FTP服务器 FTP服务器的主配置文件是 vsftpd. conf,位于/ etc/vsftpd目录下,对FP服务器的配置 其实就是对 vsftpd. conf文件的修改 另外,还有两个辅助配置文件:/ etc/vsftpd/ftpusers和/ etc/vsftpd/user list etc/vsftpd/ftpusers中指定了哪些用户不能访问FTP服务器 etc/vsftpd/user list中指定的用户在 userlist enable=yES且 userlist deny=YES时不能访 问FTP服务器。当 userlist enable=YES且 userlist deny=NO仅允许 /etc/vsftpd/user list中指 定的用户访问FTP服务器 妒实例815认识FTP服务器的默认配置。 默认主配置文件/ etc/vsftpd/vsftpd. conf中的主要语句及其说明见表8-16 表8-16默认主配置文件 vsftpd. conf及其说明 配置语句 anonymous enable=YES 允许匿名登录 允许本地用户登录 开放本地用户写的权限 设置本地用户的文件生成掩码 essage enable=yes 当切换到目录时,显示该目录下的 message隐含文件 xferlog enable=YE connect_from_port20=YES开启FIP数据端口的连接请求 erlog std format=YES 使用标准的 ftpd ferlo格 vsftpd设置PAM认证服务的配置文件名 serlist enable=YE 激活 vsftpd检査 userlist file指定的用户是否可以访问 vsftpd服务器 使 vsftpd服务器处于独立启动模式 tcp wrappers=YES 使用 tcp_ wrappers作为主机访问控制方式 第1步:编辑/ar/ named/ chroot/var/ namedtest. edu. cn. db文件 按照82节介绍的方法,编辑 test edu. cn db文件。在 test edu. cn域中添加一主机,域名 为 ftp. test. edu.cn。添加的A记录如下所示。保存该文件 ftp IN A 222. 11. 22.11 第2步:启动服务器 执行命令# service named start启动DNS服务器。 执行命令# service vsftpd start启动FTP服务器。 第3步:匿名访问FTP服务器 使用FTP客户端连接本地FTP服务器,使用匿名FTP帐号(fp)登录,如下所示 [root@localhostvsftpd]#ftpftptest.edu.cn Connected to ftp test. edu. cn. 0(vSFTPd 2.0.5) 530 Please login with USER and PASS 530 Please login with USER and pass

8.4.1 FTP 概述 FTP 协议定义了一个在远程计算机系统和本地计算机系统之间传输文件的一个标准。 FTP 位于 OSI 参考模型的应用层,并利用 TCP 协议在不同主机间提供可靠的数据传输服务 8.4.2 实例—设置 FTP 服务器 FTP 服务器的主配置文件是 vsftpd.conf,位于/etc/vsftpd 目录下,对 FTP 服务器的配置 其实就是对 vsftpd.conf 文件的修改。 另外,还有两个辅助配置文件:/etc/vsftpd/ftpusers 和/etc/vsftpd/user_list。 /etc/vsftpd/ftpusers 中指定了哪些用户不能访问 FTP 服务器。 /etc/vsftpd/user_list 中指定的用户在 userlist_enable=YES 且 userlist_deny=YES 时不能访 问 FTP 服务器。当 userlist_enable=YES 且 userlist_deny=NO 仅允许/etc/vsftpd/user_list 中指 定的用户访问 FTP 服务器。 实例 8-15 认识 FTP 服务器的默认配置。 默认主配置文件/etc/vsftpd/vsftpd.conf 中的主要语句及其说明见表 8-16。 表 8-16 默认主配置文件 vsftpd.conf 及其说明 配置语句 功能 anonymous_enable=YES 允许匿名登录 local_enable=YES 允许本地用户登录 write_enable=YES 开放本地用户写的权限 local_umask=022 设置本地用户的文件生成掩码 dirmessage_enable=YES 当切换到目录时,显示该目录下的.message 隐含文件 xferlog_enable=YES 激活上传与下载日志 connect_from_port_20=YES 开启 FTP 数据端口的连接请求 xferlog_std_format=YES 使用标准的 ftpd xferlog 格式 pam_service_name=vsftpd 设置 PAM 认证服务的配置文件名 userlist_enable=YES 激活 vsftpd 检查 userlist_file 指定的用户是否可以访问 vsftpd 服务器 listen=YES 使 vsftpd 服务器处于独立启动模式 tcp_wrappers=YES 使用 tcp_wrappers 作为主机访问控制方式 第 1 步:编辑/var/named/chroot/var/named/test.edu.cn.db 文件 按照 8.2 节介绍的方法,编辑 test.edu.cn.db 文件。在 test.edu.cn 域中添加一主机,域名 为 ftp.test.edu.cn。添加的 A 记录如下所示。保存该文件。 ftp IN A 222.11.22.11 第 2 步:启动服务器 执行命令# service named start 启动 DNS 服务器。 执行命令# service vsftpd start 启动 FTP 服务器。 第 3 步:匿名访问 FTP 服务器 使用 FTP 客户端连接本地 FTP 服务器,使用匿名 FTP 帐号(ftp)登录,如下所示。 [root@localhost vsftpd]# ftp ftp.test.edu.cn Connected to ftp.test.edu.cn. 220 (vsFTPd 2.0.5) 530 Please login with USER and PASS. 530 Please login with USER and PASS

KERBEROS V4 rejected as an authentication typ Name(ftp test. edu. cn root): ftp ∥使用匿名FTP帐号(fp)登录 331 Please specify the password 密码为空 Using binary mode to transfer files p> dir 执行dr命令,查看/atp目录下的内容 227 Entering Passive Mode(222, 11, 22, 11, 226, 112) 150 Here comes the directory listing 4096May240407pub 226 Directory send OK. ub目录 250 Directory successfully changed. 227 Entering Passive Mode(222, 11, 22, 11, 183, 77) 150 Here comes the directory list rw-r--r-- 5 May 24 04: 07 filel. txt 226 Directory send OK. p> get filel. txt ∥下载 at/ftp/pub/filel.t文件到 /etc/vsftpd目录 local: file l. txt remote: file l txt 227 Entering Passive Mode(222, 11, 22, 11, 190, 206) 50 Opening BINARY mode data connection for filel. txt(5 bytes) 226 File send OK. 5 bytes received in 0.00014 seconds(36 Kbytes/s) p> mkdir dirl ∥创建目录失败,因为没有该权限 550 Permission denied ∥退出 221 Goodbye 实例8-16使匿名用户能够上传文件 第1步:修改etc/stpd/ vsftpd.conf文件 如下所示,有两个配置选项前面有“#”号,将其删除。 #anon upload enable=YEs ∥允许匿名用户上传文件 Uncomment this if you want the anonymous FTP user to be able to create #f new directories fanon mkdir write enablesyes ∥开启匿名用户的写和创建目录的权限 第2步:创建上传目录 如下所示,在/a/ftp目录下创建上传目录 upload,并且修改该目录的权限,使其他用 户可写。 [root@localhost dir /var/ftp/uplo talocalhe od o+w /var/ft 第3步:重启FTP服务器 执行命令# service vsftpd restart重启FTP服务器。 第4步:设置 SELinux 进行如图8-39所示的设置

KERBEROS_V4 rejected as an authentication type Name (ftp.test.edu.cn:root): ftp //使用匿名 FTP 帐号(ftp)登录 331 Please specify the password. Password: //密码为空 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> dir //执行 dir 命令,查看/vat/ftp 目录下的内容 227 Entering Passive Mode (222,11,22,11,226,112) 150 Here comes the directory listing. drwxr-xr-x 2 0 0 4096 May 24 04:07 pub 226 Directory send OK. ftp> cd pub //进入/vat/ftp/pub 目录 250 Directory successfully changed. ftp> dir 227 Entering Passive Mode (222,11,22,11,183,77) 150 Here comes the directory listing. -rw-r--r-- 1 0 0 5 May 24 04:07 file1.txt 226 Directory send OK. ftp> get file1.txt //下载/vat/ftp/pub/file1.txt 文件到/etc/vsftpd 目录 local: file1.txt remote: file1.txt 227 Entering Passive Mode (222,11,22,11,190,206) 150 Opening BINARY mode data connection for file1.txt (5 bytes). 226 File send OK. 5 bytes received in 0.00014 seconds (36 Kbytes/s) ftp> mkdir dir1 //创建目录失败,因为没有该权限 550 Permission denied. ftp> quit //退出 221 Goodbye. [root@localhost vsftpd]# 实例 8-16 使匿名用户能够上传文件 第 1 步:修改/etc/vsftpd/vsftpd.conf 文件 如下所示,有两个配置选项前面有“#”号,将其删除。 #anon_upload_enable=YES 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 anon_mkdir_write_enable=YES //开启匿名用户的写和创建目录的权限 第 2 步:创建上传目录 如下所示,在/var/ftp 目录下创建上传目录 upload,并且修改该目录的权限,使其他用 户可写。 [root@localhost ~]# mkdir /var/ftp/upload [root@localhost ~]# chmod o+w /var/ftp/upload/ 第 3 步:重启 FTP 服务器 执行命令# service vsftpd restart 重启 FTP 服务器。 第 4 步:设置 SELinux 进行如图 8-39 所示的设置

文件G)帮助④ File Labeling E Allow ftpd to run directly without inetd Network Port D Allow ftp servers to use cifs used for public file transfer services Allow ttp servers to use nfs used for public file transter services D Allow ftp to read/write files in the user home directories D Disable SELinux protection for ftpd daemon Httpd Service Memory Protection 图8-39设置 SELinuX 第5步:修改目录 upload的 SELinuX属性 执行的命令如下所示。 root(@localhost -]#ls-IZ/a drwxr-xr-X root root system u: object r public content t pub drwxr-xrwx root rootroot object public content t upload rootalocalhost~# cheon-R- t public content rw t/ar/ tp/upload∥修改目录 upload的 SELinUX属性 第6步:重启FTP服务器 执行命令# service vsftpd restart重启FTP服务器 第7步:匿名访问FTP服务器 使用FTP客户端连接本地FP服务器,使用匿名FTP帐号(ftp)登录,如下所 [root@localhost-]#ftpftp.test.edu.cn Connected to ftp test. edu.cn. 220( vsFTPd2.0.5) 0 Please login with USER and PASS. 30 Please login with USER and PASS KERBEROS V4 rejected as an authentication type Name(ftp tested. cn root): ftp ∥使用匿名FTP帐号(印)登录 331 Please specify the pas ∥密码为空 230 Login successful Remote system type is UNIX ftp> dir ∥执行dr命令,查看Natp目录下的内容 227 Entering Passive Mode(222, 11, 22, 11, 214, 211) 150 Here comes the directory listing 4096May240407pub 4096 May 24 07: 37 upload 226 Directory send OK. /进入 rat/ftp/upload目录 250 Directory successfully changed ftp>Pwd ∥执行 Shell命令,显示当前路径 ∥行She命令,显示当前目录的内容

图8-39 设置SELinux 第 5 步:修改目录 upload 的 SELinux 属性 执行的命令如下所示。 [root@localhost ~]# ls -lZ /var/ftp/ drwxr-xr-x root root system_u:object_r:public_content_t pub drwxr-xrwx root root root:object_r:public_content_t upload [root@localhost ~]# chcon -R -t public_content_rw_t /var/ftp/upload/ //修改目录 upload 的 SELinux 属性 [root@localhost ~]# 第 6 步:重启 FTP 服务器 执行命令# service vsftpd restart 重启 FTP 服务器。 第 7 步:匿名访问 FTP 服务器 使用 FTP 客户端连接本地 FTP 服务器,使用匿名 FTP 帐号(ftp)登录,如下所示。 [root@localhost ~]# ftp ftp.test.edu.cn Connected to ftp.test.edu.cn. 220 (vsFTPd 2.0.5) 530 Please login with USER and PASS. 530 Please login with USER and PASS. KERBEROS_V4 rejected as an authentication type Name (ftp.test.edu.cn:root): ftp //使用匿名 FTP 帐号(ftp)登录 331 Please specify the password. Password: //密码为空 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> dir //执行 dir 命令,查看/vat/ftp 目录下的内容 227 Entering Passive Mode (222,11,22,11,214,211) 150 Here comes the directory listing. drwxr-xr-x 2 0 0 4096 May 24 04:07 pub drwxr-xrwx 2 0 0 4096 May 24 07:37 upload 226 Directory send OK. ftp> cd upload //进入/vat/ftp/upload 目录 250 Directory successfully changed. ftp> !pwd //执行 Shell 命令,显示当前路径 /root ftp> !dir //执行 Shell 命令,显示当前目录的内容 anaconda-ks.cfg Desktop install.log.syslog sh_script txtfile

CentoS-Base repo install log scsrun log temp yum-3.0.5-1.el5.centos 5. noarch rpm p> put install log ∥将本地文件 install log上传到FTP服务器 local: install log remote: install log 227 Entering Passive Mode(222, 11, 22, 11, 173, 250) 150 Ok to send data. 226 File receive OK. 36994 bytes sent in 0.013 seconds(2.8e+03 Kbytes/s) ∥上传成功 227 Entering Passive Mode(222, 11, 22, 11, 211, 1) 150 Here comes the directory listing 36994 May 2407: 48 install log 226 Directory send OK. 0> mkdir dirI ∥建目录成功 257"/upload/dir l"created ftp> quit ∥退出 22 1 Goodby FTP信息代码及其含义见附录2表2-1。 FTP使用的内部命令及其功能见附录2表2-2 实例817配置基于本地用户的访间控制 配置基于本地用户的访问控制,可以通过修改 vsftpd. conf文件来实现。该文件中要有以 下三条语句: userlist file=/etc/vsftpd/user list 他们的功能是,使得/ etc/vsftpd/user list文件中指定的本地用户,可以访问FTP服务器, 而其他本地用户不能访问FTP服务器。若将 userlist deny进行如此赋值: userlist deny=YES 则使得/ etc/vsftpd/ user list文件中指定的本地用户,不能访问FTP服务器,而其他本地用户 可以访问FTP服务器

CentOS-Base.repo install.log scsrun.log temp yum-3.0.5-1.el5.centos.5.noarch.rpm ftp> put install.log //将本地文件 install.log 上传到 FTP 服务器 local: install.log remote: install.log 227 Entering Passive Mode (222,11,22,11,173,250) 150 Ok to send data. 226 File receive OK. 36994 bytes sent in 0.013 seconds (2.8e+03 Kbytes/s) ftp> dir //上传成功 227 Entering Passive Mode (222,11,22,11,211,1) 150 Here comes the directory listing. -rw------- 1 14 50 36994 May 24 07:48 install.log 226 Directory send OK. ftp> mkdir dir1 //创建目录成功 257 "/upload/dir1" created ftp> quit //退出 221 Goodbye. FTP 信息代码及其含义见附录 2 表 2-1。 FTP 使用的内部命令及其功能见附录 2 表 2-2。 实例 8-17 配置基于本地用户的访问控制 配置基于本地用户的访问控制,可以通过修改 vsftpd.conf 文件来实现。该文件中要有以 下三条语句: userlist_enable=YES userlist_deny=NO userlist_file=/etc/vsftpd/user_list 他们的功能是,使得/etc/vsftpd/user_list 文件中指定的本地用户,可以访问 FTP 服务器, 而其他本地用户不能访问 FTP 服务器。若将 userlist_deny 进行如此赋值:userlist_deny=YES, 则使得/etc/vsftpd/user_list 文件中指定的本地用户,不能访问 FTP 服务器,而其他本地用户 可以访问 FTP 服务器

点击下载完整版文档(DOC)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
已到末页,全文结束
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有