首页 > 其他分享 >搭建FTP服务器步骤

搭建FTP服务器步骤

时间:2023-10-11 16:56:05浏览次数:25  
标签:FTP service firewalld vsftpd 服务器 hellodba root 搭建

CentOS Linux 7.6 部署FTP教程

原创 Hello DBA Hello DBA 2023-09-24 20:55 发表于江苏 收录于合集#Linux2个

 


今天给大家介绍下在CentOS 7.6操作系统上部署FTP的过程,有需要的朋友参考。


 

墨天轮:https://www.modb.pro/u/15854

公众号:Hello DBA

 


 

一、前言

FTP是一个用于在网络中传输文件的协议,可用于文件传输、网站管理、文件备份和软件发布等多种用途。

 

二、安装前准备

1、环境介绍

 

        类目                       详情
OS CentOS Linux release 7.6
HOSTNAME hellodba
IP 192.168.0.52
CPU 2C
Memory 4G
Disk 80G /
4G /swap
30G /FTP

 

2、前期准备

2.1、挂载光驱

[root@hellodba ~]# mount /dev/cdrom /mntmount: /dev/sr0 is write-protected, mounting read-only

 

2.2、配置YUM源

[root@hellodba ~]# cd /etc/yum.repos.d[root@hellodba yum.repos.d]# mkdir bak[root@hellodba yum.repos.d]# mv *.repo bak[root@hellodba yum.repos.d]# vi hellodba.repo[EL]name=Linux 7.6 DVDbaseurl=file:///mntgpgcheck=0enabled=1
[root@hellodba yum.repos.d]# yum clean allLoaded plugins: fastestmirror, langpacksCleaning repos: ELCleaning up list of fastest mirrors

 

2.3、关闭SELINUX

[root@hellodba ~]# vi /etc/selinux/config//将SELINUX=enforcing//改为SELINUX=disabled
[root@hellodba ~]# setenforce 0[root@hellodba ~]# getenforce Permissive

 

2.4、关闭防火墙

//查看防火墙状态[root@hellodba ~]# systemctl status firewalld● firewalld.service - firewalld - dynamic firewall daemon   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)   Active: active (running) since Fri 2023-09-01 13:16:41 CST; 9s ago     Docs: man:firewalld(1) Main PID: 77721 (firewalld)    Tasks: 2   CGroup: /system.slice/firewalld.service           └─77721 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Sep 01 13:16:41 hellodba systemd[1]: Starting firewalld - dynamic firewall daemon...Sep 01 13:16:41 hellodba systemd[1]: Started firewalld - dynamic firewall daemon.
//关闭防火墙[root@hellodba ~]# systemctl stop firewalld//禁止防火墙开机自动启动[root@hellodba ~]# systemctl disable firewalldRemoved symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
//查看防火墙状态[root@hellodba ~]# systemctl status firewalld● firewalld.service - firewalld - dynamic firewall daemon   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)   Active: inactive (dead)     Docs: man:firewalld(1)
Sep 01 13:16:41 hellodba systemd[1]: Starting firewalld - dynamic firewall daemon...Sep 01 13:16:41 hellodba systemd[1]: Started firewalld - dynamic firewall daemon.Sep 01 13:17:06 hellodba systemd[1]: Stopping firewalld - dynamic firewall daemon...Sep 01 13:17:07 hellodba systemd[1]: Stopped firewalld - dynamic firewall daemon.

 

3、添加用户并限制目录及指定用户访问指定目录

3.1、创建 FTP专用目录

//创建FTP用户访问目录[root@hellodba ~]# mkdir -p /FTP/data/ceshi[root@hellodba ~]# chmod -R 775 /FTP/data/ceshi[root@hellodba ~]# ls -ld /FTP/data/ceshi/drwxrwxr-x. 2 root root 6 Sep  2 17:44 /FTP/data/ceshi/

 

3.2、建立FTP用户并指定目录

[root@hellodba ~]# useradd -g root -M -d /FTP/data/ceshi -s /sbin/nologin ceshi[root@hellodba ~]# passwd ceshiChanging password for user ceshi.New password: ceshiBAD PASSWORD: The password is shorter than 8 charactersRetype new password: ceshipasswd: all authentication tokens updated successfully.

 

3.3、修改 /etc/shells

[root@hellodba ~]# vi /etc/shells/sbin/nologin--说明 /etc/shells文件的作用:1) 系统某些服务在运行过程中,会去检查用户使用的shells,而这些shell查询就是借助/etc/shells这个文件。2) 上面创建的FTP用户解释器为 /sbin/nologin,系统默认的 /etc/shells 文件里没有添加 /sbin/nologin,所以需将 /sbin/nologin 加入到 /etc/shells 文件中,否则FTP用户登录不了FTP服务。

 

三、安装vsftpd服务

1、通过YUM 安装vsftpd软件

[root@hellodba ~]# yum install -y vsftpdLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfileResolving Dependencies--> Running transaction check---> Package vsftpd.x86_64 0:3.0.2-25.el7 will be installed--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================================== Package                                      Arch                                         Version                                             Repository                                Size==============================================================================================================================================================================================Installing: vsftpd                                       x86_64                                       3.0.2-25.el7                                        EL                                       171 k
Transaction Summary==============================================================================================================================================================================================Install  1 Package
Total download size: 171 kInstalled size: 353 kDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction  Installing : vsftpd-3.0.2-25.el7.x86_64                                                                                                                                                 1/1  Verifying  : vsftpd-3.0.2-25.el7.x86_64                                                                                                                                                 1/1
Installed:  vsftpd.x86_64 0:3.0.2-25.el7                                                                                                                                                                
Complete![root@hellodba ~]# yum install -y ftpLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfileResolving Dependencies--> Running transaction check---> Package ftp.x86_64 0:0.17-67.el7 will be installed--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================================== Package                                    Arch                                          Version                                             Repository                                 Size==============================================================================================================================================================================================Installing: ftp                                        x86_64                                        0.17-67.el7                                         EL                                         61 k
Transaction Summary==============================================================================================================================================================================================Install  1 Package
Total download size: 61 kInstalled size: 96 kDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction  Installing : ftp-0.17-67.el7.x86_64                                                                                                                                                     1/1  Verifying  : ftp-0.17-67.el7.x86_64                                                                                                                                                     1/1
Installed:  ftp.x86_64 0:0.17-67.el7                                                                                                                                                                    
Complete!

 

2、配置vsftpd服务

[root@hellodba ~]# cd /etc/vsftpd/[root@hellodba vsftpd]# ll-rw-------. 1 root root  125 Oct 31  2018 ftpusers-rw-------. 1 root root  361 Oct 31  2018 user_list-rw-------. 1 root root 5116 Oct 31  2018 vsftpd.conf-rwxr--r--. 1 root root  338 Oct 31  2018 vsftpd_conf_migrate.sh[root@hellodba vsftpd]# cp vsftpd.conf vsftpd.conf_bak[root@hellodba vsftpd]# vi vsftpd.confanonymous_enable=NOlocal_enable=YESwrite_enable=YESlocal_umask=000dirmessage_enable=YESxferlog_enable=YESconnect_from_port_20=YESxferlog_std_format=YESchroot_list_enable=YESchroot_list_file=/etc/vsftpd/chroot_listlisten=NOlisten_ipv6=YES
pam_service_name=vsftpduserlist_enable=YEStcp_wrappers=YESallow_writeable_chroot=YES

//创建 chroot_list 文件并添加FTP用户[root@hellodba vsftpd]# vi chroot_listceshi

 

3、重启FTP服务

[root@hellodba ~]# systemctl restart vsftpd[root@hellodba ~]# systemctl status vsftpd● vsftpd.service - Vsftpd ftp daemon   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)   Active: active (running) since Sat 2023-09-02 13:21:31 CST; 12s ago  Process: 19364 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS) Main PID: 19365 (vsftpd)    Tasks: 1   CGroup: /system.slice/vsftpd.service           └─19365 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Sep 02 13:21:31 hellodba systemd[1]: Starting Vsftpd ftp daemon...Sep 02 13:21:31 hellodba systemd[1]: Started Vsftpd ftp daemon.

 

四、登录测试

[root@hellodba ~]# touch /FTP/data/ceshi/test.log[root@hellodba ~]# ftp 192.168.0.52Connected to 192.168.0.52 (192.168.0.52).220 (vsFTPd 3.0.2)Name (192.168.0.52:root): ceshi331 Please specify the password.Password:230 Login successful.Remote system type is UNIX.Using binary mode to transfer files.ftp> ls227 Entering Passive Mode (192,168,0,52,55,10).150 Here comes the directory listing.-rw-r--r--    1 0        0               0 Sep 02 10:12 test.log226 Directory send OK.ftp> pwd257 "/"

 

图片

图片

 

五、常用命令

// 启动FTP[root@hellodba ~]# systemctl start vsftpd.service  
//设置开机自动启动[root@hellodba ~]# systemctl enable vsftpd.service
//停止FTP[root@hellodba ~]# systemctl stop vsftpd.service
//查看FTP状态[root@hellodba ~]# systemctl status vsftpd● vsftpd.service - Vsftpd ftp daemon   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)   Active: active (running) since Sat 2023-09-23 19:56:17 CST; 5s ago  Process: 20167 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS) Main PID: 20168 (vsftpd)    Tasks: 1   CGroup: /system.slice/vsftpd.service           └─20168 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Sep 23 19:56:17 hellodba systemd[1]: Starting Vsftpd ftp daemon...Sep 23 19:56:17 hellodba systemd[1]: Started Vsftpd ftp daemon.
//查看FTP端口[root@hellodba ~]# netstat -antup | grep ftptcp6       0      0 :::21                   :::*                    LISTEN      20168/vsftpd

 

六、写在后面

到此,基于CentOS Linux 7.6 部署FTP部署完毕。由于本人有限的能力和知识储备,如有错误敬请批评指正!

 



THE END



 

 

Hello DBA 一名无人知晓、平凡无奇的DBA。茶余饭后分享一些关于数据库方面的实操与心得。因本人能力和水平有限,定有错误和疏漏之处,敬请批评指正! 3篇原创内容 公众号 收录于合集 #Linux  2个 上一篇SUSE Linux Enterprise Server 12 SP5 终端显示设置   阅读原文 阅读 375 Hello DBA   ​ 收藏此内容的人还喜欢   实操指南:一步步教你在Red Hat Linux 7.6文件系统安装Oracle 11g数据库,并解决常见安装问题!     Hello DBA 不看的原因   CXL技术研究(三)——Linux驱动程序     布鲁斯的读书圈 不看的原因   等保2.0测评深入理解—Linux操作系统(二)     等保不好做啊 不看的原因     关注后可发消息         复制搜一搜分享收藏划线    

人划线

标签:FTP,service,firewalld,vsftpd,服务器,hellodba,root,搭建
From: https://www.cnblogs.com/cherishthepresent/p/17757609.html

相关文章

  • 方案:餐厅饭店AI智能视频监控可视化监管系统搭建方案
    随着大众对食品卫生的要求逐渐提升,明厨亮灶已成为很多人选择就餐点的一大要求,明厨亮灶的产生对保障大众食安起到了十分显著的作用,后厨作为食品安全重要场所,需要“亮”出来,前厅也同时需要监控系统的保护,那么智能分析算法可以怎样应用在饭店和餐馆日常监控之中呢?具体方案1、视频监......
  • 方案:餐厅饭店AI智能视频监控可视化搭建方案
    随着大众对食品卫生的要求逐渐提升,明厨亮灶已成为很多人选择就餐点的一大要求,明厨亮灶的产生对保障大众食安起到了十分显著的作用,后厨作为食品安全重要场所,需要“亮”出来,前厅也同时需要监控系统的保护,那么智能分析算法可以怎样应用在饭店和餐馆日常监控之中呢?具体方案1、视频监控......
  • WebAssembly C++开发环境搭建
    WebAssembly开发环境搭建简介WebAssembly是一种新的编码方式,可以在现代的网络浏览器中运行-它是一种低级的类汇编语言,具有紧凑的二进制格式,可以接近原生的性能运行,并为诸如C/C++等语言提供一个编译目标,以便它们可以在Web上运行。它也被设计为可以与JavaScript共存,允许两......
  • 基于 ACK Fluid 的混合云优化数据访问(二):搭建弹性计算实例与第三方存储的桥梁
    作者:车漾前文回顾:本系列将介绍如何基于ACKFluid支持和优化混合云的数据访问场景,相关文章请参考:基于ACKFluid的混合云优化数据访问(一):场景与架构在前文《场景与架构》中,重点介绍ACKFluid支持混合云数据访问适用的不同应用场景和架构实现。在本文中会重点介绍如何通过ACKFl......
  • 监听上传的服务器文件是否改变,从而刷新页面
     监听上传的服务器文件是否改变,从而刷新页面=>interfaceOptions{timer?:number;}classUpdater{oldScript:string[];//存储第一次值也就是script的hash信息newScript:string[];//获取新的值也就是新的script的hash信息dispatch:Record<string,Fun......
  • 服务器上清理Docker容器运行日志的正确姿势
    文章目录@[toc]1.为啥要清理服务器上docker容器的日志?2.docker容器日志限制2.1容器范围内2.2全局范围内3.删除Docker容器日志的正确姿势3.1方式一:3.2方式二:1.为啥要清理服务器上docker容器的日志?  因为是服务器的磁盘空间资源法律有限,由于d......
  • 天堂2服务器基本设置
    [system]server_name=LocalServer——〉服务器名称server_rules=PvPhttp_host=127.0.0.1——〉HTTP注册页面(需先搭建IIS服务器)http_port=8080rs_host=127.0.0.1——〉填IPrs_port=3724ws_host=127.0.0.1——〉填你的IPws_port=8085world_sleep_ms=500——〉照字面来看是白天的......
  • 服务器E5跟I9的区别
    在如今互联网的高速发展,服务器的运用场景也是越来越多,用到的人群也是很广泛。当我们在选择服务器的时候会有各种各样的配置让我们眼花缭乱不知道该怎么去选择,下面我跟大家分享一下E5跟I9有什么区别我们在选择的是时候该怎么去选择合适自己的服务器。首先配置方面E5具备强大的处理能......
  • 基于亚马逊云科技高可靠性的EC2云服务器,搭建功能无限制的私人网盘
    网盘是一种在线存储服务,提供文件存储,访问,备份,贡献等功能,是我们日常中不可或缺的一种服务。很多互联网公司都为个人和企业提供免费的网盘服务。但这些免费服务都有一些限制,比如限制下载速度,限制文件大小,不能多人同时管理,不能实现一些定制化功能。如果想取消这些限制,就要付费。现在为......
  • DELL R730 idrace web页面无法显示,可不重启服务器,ssh登录重启idrace服务
    故障现象:Dell服务器带外管理Idrace的web页面无法显示。处理过程:  无需冷启动服务器  ssh登录Dell服务器带外管理地址用户名与密码同为登录web页面账号密码  运行重启命令:racadmracreset  等待约2分钟后,Idrace带外管理web页面恢复正常显示,可正常登录。racadmrac......