你好,游客 登录 注册 搜索
背景:
阅读新闻

Red Hat Enterprise Linux 6.2搭建FTP服务器

[日期:2015-08-16] 来源:Linux社区  作者:静以致远√团团 [字体: ]

我的环境:
A:Red Hat Enterprise Linux 6.2 IP:192.168.16.12 此机作测试端
B:Red Hat Enterprise Linux 6.2 IP:192.168.16.13 此机做FTP服务端
 
B机上搭建FTP服务器:
下载并安装vsftpd-2.2.2-6.el6_0.1.i686
[root@RedHat6-3 ~]# rpm -ivh vsftpd-2.2.2-6.el6_0.1.i686.rpm
创建测试用户:
[root@redhat6-3 ~]# useradd linuxidc -d /var/ftp/ttftp -s /sbin/nologin
[root@redhat6-3 ~]# useradd linuxidc -s /sbin/nologin
[root@redhat6-3 ~]# passwd linuxidc
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
 
查看一下新创建的用户配置
[root@redhat6-3 ~]# tail -1 /etc/passwd
linuxidc:x:504:504::/var/ftp/ttftp:/sbin/nologin
 
修改配置文件:
首先来看vsftp的配置文件,常使用的配置如下:
[root@redhat6-3 ~]# grep -v "#" /etc/vsftpd/vsftpd.conf
anonymous_enable=YES    //是否启动匿名用户登入
local_enable=YES      //是否允许本地用户登入
write_enable=YES      //是否允许用户写入
local_umask=022      //用户目录下创建文件默认权限,此处默认权限是777-022=755
dirmessage_enable=YES
xferlog_enable=YES    //是否使用日志
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES    //是否使用监听,若不使用将使用超级守护进程
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES    //是否启用用/etc/hosts.allow或/etc/hosts.deny文件生效
以上是默认的ftp参数,我们还需添加以下参数来完成配置:
chroot_local_user=YES    //是否禁止本地用户离开自己的主目录
xferlog_file=/var/log/vsftpd.log      //设置ftp的日志路径
idle_session_timeout=600      //设置回话等待时间
data_connection_timeout=120    //设置数据等待时间
ftpd_banner=Welcome to connect my FTP!    //设置成功登入提示
 
完成配置后重启一下ftp,查看进程并在A机上登入测试:
[root@redhat6-3 ~]# netstat -antp|grep 21
tcp        0      0 0.0.0.0:111    0.0.0.0:*        LISTEN  1221/rpcbind       
tcp        0      0 0.0.0.0:21      0.0.0.0:*        LISTEN  1926/vsftpd       
tcp        0      0 :::111            :::*                LISTEN  1221/rpcbind       
客户端需安装ftp-0.17-51.1.el6.i686来支持ftp命令
在A上:
[root@redhat6-2 Packages]# rpm -ivh ftp-0.17-51.1.el6.i686.rpm
[root@redhat6-2 Packages]# ftp 192.168.16.13
Connected to 192.168.16.13 (192.168.16.13).
220 Welcome to connect my FTP!
Name (192.168.16.13:root): linuxidc
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
help命令查看ftp的命令
ftp>help
Commands may be abbreviated.  Commands are:
!                  debug              mdir            sendport        site
$                  dir                  mget            put            size
account        disconnect      mkdir          pwd            status
append          exit                mls            quit            struct
ascii              form            mode            quote          system
bell                get            modtime        recv            sunique
binary            glob            mput            reget          tenex
bye              hash            newer          rstatus        tick
case            help            nmap            rhelp          trace
cd                idle              nlist          rename          type
cdup            image          ntrans          reset          user
chmod          lcd            open            restart        umask
close            ls              prompt          rmdir          verbose
cr                macdef          passive        runique        ?
delete          mdelete        proxy          send
创建一个目录,并想改目录内传送一个文件:
ftp> cd test
250 Directory successfully changed.
ftp> !ls
anaconda-ks.cfg    LAMP        mysql-5.5.25.tar.gz
install.log        mysql-5.1.66-linux-i686-glibc23.tar.gz
ftp> put mysql-5.5.25.tar.gz
local: mysql-5.5.25.tar.gz remote: mysql-5.5.25.tar.gz
227 Entering Passive Mode (192,168,16,13,216,59).
150 Ok to send data.
226 Transfer complete.
24639871 bytes sent in 1.1 secs (22359.01 Kbytes/sec)
切换到服务端查看该目录下的文件:
[root@redhat6-3 ~]# cd /var/ftp/ttftp/test/
[root@redhat6-3 test]# ls
mysql-5.5.25.tar.gz
也可以在windows下登入该ftp,更加方便:
打开我的电脑输入ftp://linuxidc@192.168.16.13 


 
配置超级守护进程启动vsftp
需要装xinetd服务管理工具:
[root@redhat6-3 ~]# rpm -ivh xinetd-2.3.14-33.el6.i686.rpm
[root@redhat6-3 ~]# cp -rf /usr/share/doc/vsftpd-2.2.2/vsftpd.xinetd  /etc/xinetd.d/vsftpd
[root@redhat6-3 ~]# vi /etc/xinetd.d/vsftpd
# default: off
# description: The vsftpd FTP server serves FTP connections. It uses \
#      normal, unencrypted usernames and passwords for authentication.
service ftp
{
        socket_type            = stream
        wait                    = no
        user                    = root
        server                  = /usr/sbin/vsftpd
        server_args            = /etc/vsftpd/vsftpd.conf
        nice                    = 10
        disable                = no  //将yes改为no即可
        flags                  = IPv4
}
修改配置文件
#listen=YES
将listen注释掉即可
建议write_enable=YES改为NO
 
将vsftpd的服务停掉:
[root@redhat6-3 xinetd.d]# service vsftpd stop
Shutting down vsftpd:                                      [  OK  ]
重启xinted服务:
[root@redhat6-3 etc]# service xinetd restart
Stopping xinetd:                                          [  OK  ]
Starting xinetd:                                          [  OK  ]
查看端口是否存在:
[root@redhat6-3 etc]# netstat -antp | grep 21
tcp        0      0 0.0.0.0:111      0.0.0.0:*      LISTEN      1221/rpcbind       
tcp        0      0 0.0.0.0:21        0.0.0.0:*        LISTEN    4369/xinetd       
tcp        0      0 :::111            :::*          LISTEN      1221/rpcbind   
因为启用超级进程来管理vsftp,所以这时候启动vsftpd会报如下错误:
[root@redhat6-3 etc]# service vsftpd start
Starting vsftpd for vsftpd: 500 OOPS: vsftpd: not configured for standalone, must be started from inetd
若不想启用超级进程管理,将配置文件中的listen=YES注释取消即可
 
测试端登入测试:
[root@redhat6-2 ~]# ftp 192.168.16.13
Connected to 192.168.16.13 (192.168.16.13).
220 Welcome to connect my FTP!
Name (192.168.16.13:root): linuxidc
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> bye
221 Goodbye.
windows登入测试:
同上次方法一样打开我的电脑或cmd(调用浏览器)输入:tp://linuxidc@192.168.16.13/


 
输入用户名和密码后登入进行操作即可
 


 
简单的ftp服务器配置完成!

CentOS 7 搭建ftp服务器  http://www.linuxidc.com/Linux/2015-06/118494.htm

CentOS 7安装配置FTP服务器 http://www.linuxidc.com/Linux/2014-11/109233.htm

Ubuntu实用简单的FTP架设 http://www.linuxidc.com/Linux/2012-02/55346.htm

Ubuntu 上架设FTP服务器和Apache服务器 http://www.linuxidc.com/Linux/2011-04/35295.htm

Ubuntu 13.04 安装 LAMP\vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm

RHEL6平台下SeLinux和vsftpd的匿名上传的简单案例 http://www.linuxidc.com/Linux/2013-04/82300.htm

更多RedHat相关信息见RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-08/121767.htm

linux
相关资讯       ftp服务器  RedHat搭建FTP服务器 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款