前言

CentOS7因为systemd取代了init,所以在配置方面和6有些不同,这篇用简洁的语言描述如何在7上开启ftp。

安装

通常安装好系统之后, vsftp已经安装好了,只需要启动一下服务就好。
如果没有安装,则建议通过yum来安装

harriszh# yum search vsftp
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftpmirror.your.org
 * epel: ftp.kddilabs.jp
 * extras: mirror.scalabledns.com
 * updates: mirror.scalabledns.com
=============================================================================================== N/S matched: vsftp ================================================================================================
vsftpd-sysvinit.x86_64 : SysV initscript for vsftpd daemon
vsftpd.x86_64 : Very Secure Ftp Daemon

然后就可以通过yum install vsftpd.x86_64来进行安装

配置

配置文件在/etc/vsftp/vsftp.conf里
一般我只修改

ascii_upload_enable=YES
ascii_download_enable=YES

其他保持默认
更复杂的配置请参考vsftp的文档

开启服务

在CentOS7中最显著的变化就是使用systemd来代替init进行启动和服务管理。所以相应命令改为

systemctl start vsftp

如果有问题可以通过systemctl status vsftpd来查看

l status vsftpd
● vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
   Active: active (running) since 六 2018-05-19 22:10:41 CST; 45min ago
  Process: 33471 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
 Main PID: 33473 (vsftpd)
    Tasks: 1
   CGroup: /system.slice/vsftpd.service
           └─33473 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

5月 19 22:10:41 centos-harriszh systemd[1]: Starting Vsftpd ftp daemon...
5月 19 22:10:41 centos-harriszh systemd[1]: Started Vsftpd ftp daemon.

防火墙

开启服务后,默认其他机器还是无法访问,通常原因都是因为防火墙
在CentOS7中,可以安装firewall-config来进行界面化的配置

centos-harriszh# yum search firewall
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftpmirror.your.org
 * epel: ftp.kddilabs.jp
 * extras: mirror.scalabledns.com
 * updates: mirror.scalabledns.com
============================================================================================== N/S matched: firewall ==============================================================================================
fail2ban-firewalld.noarch : Firewalld support for Fail2Ban
firewall-applet.noarch : Firewall panel applet
firewall-config.noarch : Firewall configuration application
firewalld.noarch : A firewall daemon with D-Bus interface providing a dynamic firewall
firewalld-filesystem.noarch : Firewalld directory layout and rpm macros
puppet-firewalld.noarch : A Puppet module for FirewallD
python-firewall.noarch : Python2 bindings for firewalld
system-config-firewall.noarch : A graphical interface for basic firewall setup
system-config-firewall-base.noarch : system-config-firewall base components and command line tool
system-config-firewall-tui.noarch : A text interface for basic firewall setup
perl-IPTables-Parse.noarch : Perl extension for parsing iptables firewall rulesets
shorewall.noarch : An iptables front end for firewall configuration
shorewall-lite.noarch : Shorewall firewall for compiled rulesets
shorewall6.noarch : Files for the IPV6 Shorewall Firewall
shorewall6-lite.noarch : Shorewall firewall for compiled IPV6 rulesets
ufw.noarch : Uncomplicated Firewall

  Name and summary matches only, use "search all" for everything.
centos-harriszh# yum install firewall-config.noarch

然后在命令行输入firewall-config就可以打开界面了
firewall-config
如上图所示在configuration处选择Permanent, 然后在trusted里把ftp勾选上就行了

总结

做完以上步骤,应该就可以在其他机器上用lftp登录到本机,并如同在本机上访问目录了


harriszh
338 声望131 粉丝

做些有趣的事,留些有用的存在