阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Red Hat Enterprise Linux 6.2搭建FTP服务器

118次阅读
没有评论

共计 5333 个字符,预计需要花费 14 分钟才能阅读完成。

我的环境:
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 

Red Hat Enterprise Linux 6.2 搭建 FTP 服务器
 
配置超级守护进程启动 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/

Red Hat Enterprise Linux 6.2 搭建 FTP 服务器

Red Hat Enterprise Linux 6.2 搭建 FTP 服务器
 
输入用户名和密码后登入进行操作即可
 

Red Hat Enterprise Linux 6.2 搭建 FTP 服务器

Red Hat Enterprise Linux 6.2 搭建 FTP 服务器
 
简单的 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

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计5333字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中