首页 > 系统相关 >Centos7 安装/卸载 vsftpd

Centos7 安装/卸载 vsftpd

时间:2023-10-24 16:06:41浏览次数:56  
标签:ftp enable Centos7 vsftpd 卸载 YES root localhost


安装vsftpd

[root@localhost ~]# yum -y  install vsftpd

查看安装路径

[root@localhost ~]# whereis vsftpd
vsftpd: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz

查看目录

[root@localhost ~]# ll /etc/vsftpd/

-rw------- 1 root root  125 Mar 22  2017 ftpusers  黑名单文件,此文件里的用户不允许访问 FTP 服务器
-rw------- 1 root root  361 Mar 22  2017 user_list  白名单文件,是允许访问 FTP 服务器的用户列表
-rw------- 1 root root 4599 Mar 22  2017 vsftpd.conf  核心配置文件
-rwxr--r-- 1 root root  338 Mar 22  2017 vsftpd_conf_migrate.sh  FTP服务

基于用户验证的ftp服务

第一步:编辑vsftpd.conf

[root@localhost ~]# cat /etc/vsftpd/vsftpd.conf | grep -v "#" > vsftpd.conf

Centos7 安装/卸载 vsftpd_运维

配置文件注释

anonymous_enable=NO # 不允许匿名,默认是NO
local_enable=YES # YES时,/etc/passwd中的账号才能以实体用户的方式访问vsftpd主机

write_enable=YES # 具有写权限
local_umask=022 # 反掩码(755权限):777-755 = 022 (755权限)
anon_umask=022
anon_upload_enable=NO # 禁止匿名用户上传
anon_other_write_enable=NO
anon_mkdir_write_enable=NO # 禁止匿名用户建立目录
dirmessage_enable=YES # YES 开启目录标语功能
xferlog_enable=YES # YES 时,上传与下载的日志存放于xferlog_file
connect_from_port_20=NO # 不开启20端口
xferlog_std_format=YES # 设定日志使用标准的记录格式
chroot_local_user=YES # YES时,不禁锢系统用户
chroot_list_enable=YES # 禁止用户登出自己的FTP主目录
chroot_list_file=/etc/vsftpd/chroot_list # 该文件中用户不受限制,不限制在本目录
listen=YES

pam_service_name=vsftpd # pam模块名称,位于/etc/pam.d/vsftpd
userlist_enable=NO
tcp_wrappers=YES # 开启tcp_wrappers管理支持

allow_writeable_chroot=YES # 解决chroot权限问题

listen_port=38001 # ftp端口号
pasv_enable=YES #启动被动式联机(passivemode)
pasv_min_port=38003
pasv_max_port=38015
ftp_data_port=38002

local_root=/mnt/devops/njss_web_system_ftp # ftp访问目录(上传默认位置)

显示带行号

[root@localhost ~]# cat /etc/vsftpd/vsftpd.conf -n

Centos7 安装/卸载 vsftpd_ci_02

配置文件内容

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES

#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
anon_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
anon_upload_enable=NO
anon_other_write_enable=NO
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=NO
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=NO
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode. The vsftpd.conf(5) man page explains
# the behaviour when these options are disabled.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=NO
tcp_wrappers=YES

allow_writeable_chroot=YES

listen_port=38001
pasv_enable=YES
pasv_min_port=38003
pasv_max_port=38015
ftp_data_port=38002

local_root=/mnt/devops/njss_web_system_ftp

第二步:更新防火墙端口

添加主端口

[root@localhost ~]firewall-cmd --permanent --zone=public --add-port=38001/tcp

添加被动端口

[root@localhost ~]firewall-cmd --permanent --zone=public --add-port=38003-38015/tcp

重启防火墙

[root@localhost ~]firewall-cmd --reload

第三步:添加用户

创建用户

[root@localhost ~]useradd -d /mnt/devops/njss_web_system_ftp/ ftpuser

useradd: cannot set SELinux context for home directory /mnt/devops/njss_web_system_ftp/

[root@localhost ~]setenforce 0

[root@localhost ~]useradd -d /mnt/devops/njss_web_system_ftp/ ftpuser

设置密码

[root@localhost ~]passwd ftpuser

第四步:修改文件夹权限

赋予文件夹读写权限

[root@localhost ~]chmod 777 /mnt/devops/njss_web_system_ftp/

[root@localhost ~]ls -ld /mnt/devops/njss_web_system_ftp/
drwxrwxrwx. 4 ftpuser2 ftpuser2 84 Oct 14 12:40 /mnt/devops/njss_web_system_ftp/

第五步:vsftpd操作

查看vsftpd状态

[root@localhost ~]# 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-10-14 15:44:03 CST; 33min ago
  Process: 8845 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
 Main PID: 8846 (vsftpd)
   CGroup: /system.slice/vsftpd.service
           ├─8846 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
           ├─9369 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
           └─9375 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

Oct 14 15:44:03 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon...
Oct 14 15:44:03 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.

启动vsftpd

[root@localhost ~]systemctl start vsftpd

停止vsftpd

[root@localhost ~]systemctl stop vsftpd

重启vsftpd

[root@localhost ~]systemctl restart vsftpd

查看ftp端口

[root@localhost ~]# netstat -npal|grep vsftpd
tcp        0      0 0.0.0.0:38001           0.0.0.0:*               LISTEN      8846/vsftpd
tcp        0      0 192.168.18.129:38001    192.168.18.129:40724    ESTABLISHED 9369/vsftpd
unix  3      [ ]         STREAM     CONNECTED     90261    9369/vsftpd
unix  2      [ ]         DGRAM                    86088    8846/vsftpd
unix  3      [ ]         STREAM     CONNECTED     90262    9375/vsftpd

第六步:ftp登录

Centos7 安装/卸载 vsftpd_ci_03

[root@localhost ~]# ftp 192.168.18.129 38001
Connected to 192.168.18.129 (192.168.18.129).
220 (vsFTPd 3.0.2)
Name (192.168.18.129:root): ftpuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

卸载vsftpd

第一步:查看vsftpd

[root@localhost ~]# rpm -qa|grep vsftpd vsftpd-3.0.2-29.el7_9.x86_64

第二步:卸载vsftped

[root@localhost ~]# rpm -e vsftpd-3.0.2-29.el7_9.x86_64

返回:卸载时自己主动备份vsftp的用户列表文件 warning: /etc/vsftpd/vsftpd.conf saved as /etc/vsftpd/vsftpd.conf.rpmsave warning: /etc/vsftpd/user_list saved as /etc/vsftpd/user_list.rpmsave

第三步:删除上面的文件

[root@localhost ~]#rm -fr /etc/vsftpd

第四步:查看vsftpd是否在开机启动项

[root@localhost ~] chkconfig --list

第五步:查看vsftpd执行状态

[root@localhost ~] service vsftpd status

返回:vsftpd: unrecognized service(无法识别vsftpd。说明卸载了vsftpd了)

防火墙操作

查看防火墙状态

[root@localhost ~]# systemctl status firewalld

关闭防火墙

[root@localhost ~]#systemctl stop firewalld

启动防火墙

[root@localhost ~]#systemctl start firewalld

重启防火墙

[root@localhost ~]#firewall-cmd --reload

用户操作

查看用户

[root@localhost ~]# cat /etc/passwd
ftpuser:x:1008:1008::/mnt/devops/njss_web_system_ftp/:/bin/bash

删除用户

[root@localhost ~]#userdel -r 用户名

参考

https://www.toutiao.com/article/6724624529643012616/?channel=&source=search_tab

centos搭建配置ftp并设置被动模式 | 码农家园

标签:ftp,enable,Centos7,vsftpd,卸载,YES,root,localhost
From: https://blog.51cto.com/u_3172968/8005184

相关文章

  • Centos7 - ftp login 530
    问题描述[root@localhostdevops]#ftp192.168.18.12938001Connectedto192.168.18.129(192.168.18.129).220(vsFTPd3.0.2)Name(192.168.18.129:root):test3331Pleasespecifythepassword.Password:530Loginincorrect.Loginfailed.查看/etc/vsftpd/ftpusers-......
  • centos7磁盘动态扩容
    1.查看磁盘空间df-h  2.fdisk-l  查看当前的磁盘分区信息(主要是分区表信息) linux新增磁盘后,用fdisk等命令查询不到#ls/sys/class/scsi_host/(会看到有host0、host1...hostN,对每个host进行如下操作) echo"---">/sys/class/scsi_host/host0/scanecho"--......
  • VMware最小化安装Centos7.6-无桌面
    目录安装包工具新建虚拟机安装centos7.6终端登陆系统设置ip地址关闭防火墙关闭SELINUXSELINUX=enforcing硬盘挂载安装包工具VMware®Workstation15Pro15.5.2build-15785246CentOS-7.6-x86_64-DVD-1810.iso链接:https://pan.baidu.com/s/1u2vMvwtpHxbNoRpvLERKmQ提取码:b8jt......
  • k8s安装与卸载chaosblade
    k8s安装与卸载chaosblade安装helm3wgethttps://get.helm.sh/helm-v3.12.3-linux-amd64.tar.gztar-zxvfhelm-v3.12.3-linux-amd64.tar.gzmvlinux-amd64/helm/usr/local/bin/helm安装chaosblade难点是下载镜像,因此需要配置加速镜像源,然后下载成功后再安装chaosblade配......
  • 卸载工具Your Uninstaller!介绍
    我们在安装某些软件的时候,由于某些原因可能破坏了原始的安装包安装的文件,造成卸载不成功。很多时候我们会考虑手动删除注册表来卸载软件。但某些变态的软件在进行检测的时候(原来的版本不删除,新版本不让安装,提示在控制面板添加删除程序删除旧版本,但在添加删除程序又找不到旧的版本存......
  • 启动vsftpd进程时报错Job for vsftpd.service failed
    问题描述:启动vsftpd进程时报错Jobforvsftpd.servicefailed,如下所示:系统:rhel7.31、异常重现[root@leo-827mgr-masterlocal]#systemctlstartvsftpdJobforvsftpd.servicefailedbecausethecontrolprocessexitedwitherrorcode.See"systemctlstatusvsftpd.ser......
  • centos7和centos8的区别
      网络管理centos7云主机:centos7使用network管理网络,NetworkManager默认是关闭的自己安装的centos7mini版:两个都是开启的 centos8centos8没有network,使用NetworkManager管理网络修改ip地址等操作之后,使用systemctlrestartNetworkManager重启网络服务 yum和dnfcentos......
  • Linux centos7网卡起不来的现象
    现象如下图:FailedtostartLSB:Bringup/downnetworking.解决方法一:一般跟系统自带的NetworkManager这个管理套件有关系,关掉就可以解决systemctlstopNetworkManger//关闭NetworkManager套件服务systemctldisalbleNetworkManager//开机自动关闭systemctkstartnetwork......
  • phpldapadmin卸载
     ldap服务器停止openldapsystemctlstopslapdsystemctldisableslapd卸载yum-yremoveopenldap-serversopenldap-clients删除残留文件rm-rf/var/lib/ldap删除ldap用户userdelldap删除openldap目录rm-rf/etc/openldaprm-rf/root/ldapldap客户端不......
  • CentOS7添加Windows字体类型
    前言:我这么做的原因是:我在windows系统使用java操作ascope的文件转换,项目开发结束,到了部署这一步,将jar包丢到了CentOS服务器上,运行后一切都很顺利,但是当远程调用接口的时候报了错误,然后我在windows系统运行jar也没有问题,那问题就出在了环境上,于是就摸到了这条线,不出所料,问题就出现......