如何在CentOS 7上使用vsftpd设置ftp服务器

时间:2021-12-10 15:42:36

一、前言介绍

FTP(文件传输协议)是一种标准的客户机-服务器网络协议,允许用户在远程网络之间传输文件。

有几个开源的FTP服务器可用于Linux。最受欢迎和广泛使用的是pureftpd、proftpd和vsftpd。

在本教程中,我们将在Centos7上安装vsftpd(非常安全的ftp守护进程)。它是一个稳定、安全和快速的FTP服务器。我们还将向您展示如何配置vsftpd,以将用户限制到其主目录,并使用ssl/tls加密整个传输。

要获得更安全和更快的数据传输,请使用SCP或SFTP。

二、先决条件

在继续本教程之前,请确保您以具有sudo权限的用户身份登录。(root 登录可以不用sudo  一般可以省略sudo )

sudo的工作过程如下:

1,当用户执行sudo时,系统会主动寻找/etc/sudoers文件,判断该用户是否有执行sudo的权限

2,确认用户具有可执行sudo的权限后,让用户输入用户自己的密码确认

3,若密码输入成功,则开始执行sudo后续的命令

4,root执行sudo时不需要输入密码(eudoers文件中有配置root ALL=(ALL) ALL这样一条规则)

5,若欲切换的身份与执行者的身份相同,也不需要输入密码

visudo使用vi打开/etc/sudoers文件,但是在保存退出时,visudo会检查内部语法,避免用户输入错误信息

visudo需要root权限

[hadoop@localhost ~]$ visudo
visudo:/etc/sudoers:权限不够
visudo:/etc/sudoers:权限不够

三、在CentOS 7上安装vsftpd

1、vsftpd包在默认的CentOS存储库中可用。要安装它,请发出以下命令:

sudo yum install vsftpd

2、安装包后,启动vsftpd守护进程并使其在启动时自动启动,vsftpd服务的状态来验证它是否正在运行

 #设置开机启动
systemctl enable vsftpd.service #启动
systemctl start vsftpd.service #停止
systemctl stop vsftpd.service #查看状态
systemctl status vsftpd.service #重启
systemctl restart vsftpd.service

具体操作如下,操作完成之后都要重启启动并且查看状态的

[root@centos001 ~]# sudo yum install vsftpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB ::
epel | 4.7 kB ::
extras | 3.4 kB ::
packages-microsoft-com-prod | 2.9 kB ::
updates | 3.4 kB ::
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 :3.0.-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved ===============================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================
Installing:
vsftpd x86_64 3.0.-.el7 base k Transaction Summary
===============================================================================================================================================
Install Package Total download size: k
Installed size: k
Is this ok [y/d/N]: y
Downloading packages:
vsftpd-3.0.-.el7.x86_64.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : vsftpd-3.0.-.el7.x86_64 /
Verifying : vsftpd-3.0.-.el7.x86_64 / Installed:
vsftpd.x86_64 :3.0.-.el7 Complete!
[root@centos001 ~]# sudo systemctl start vsftpd
[root@centos001 ~]# sudo systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[root@centos001 ~]# sudo systemctl enable vsftpd
[root@centos001 ~]# systemctl status vsftpd
● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
Active: active (running) since Wed -- :: CST; 48s ago
Main PID: (vsftpd)
CGroup: /system.slice/vsftpd.service
└─ /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf May :: centos001 systemd[]: Starting Vsftpd ftp daemon...
May :: centos001 systemd[]: Started Vsftpd ftp daemon.
[root@centos001 ~]#
四、配置vsftpd(重点标记,我自己错误了好多次才成功的,错了就删除了重新配置)

  配置vsftpd服务涉及编辑/etc/vsftpd/vsftpd.conf配置文件。大多数设置都在配置文件中有很好的文档记录。有关所有可用选项,请访问官方vsftpd页面。 http://vsftpd.beasts.org/vsftpd_conf.html(官方介绍,比较好用,英文不好的戳这里:https://www.cnblogs.com/sopcce/p/10743359.html

在下面的部分中,我们将介绍配置安全vsftpd安装所需的一些重要设置。

1、首先打开vsftpd配置文件:

 vi /etc/vsftpd/vsftpd.conf

2、编辑配置文件(  配置文件 /etc/vsftpd/vsftpd.conf,修改:wq  )

anonymous_enable=N0
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
ftpd_banner=Welcome to blah FTP service.
userlist_file=/etc/vsftpd/user_list 
userlist_deny=YES
user_sub_token=$USER 
local_root=/home/$USER/ftp 
pasv_min_port=30000 
pasv_max_port=31000 

原来的配置文件如下,记得备份文件哦

[root@centos----20G ~]#  vi /etc/vsftpd/vsftpd.conf

# 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. for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf. 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=YES
#
# 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 . You may wish to change this to ,
# if your users expect that ( is used by most other ftpd's)
local_umask=
#
# 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=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# 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 (ftp-data).
connect_from_port_20=YES
#
# 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.
#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
# 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=
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=
#
# 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() 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
# 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=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# 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 (ftp-data).
connect_from_port_20=YES
#
# 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=
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=
#
# 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() 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
# 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=NO
#
# 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=YES
tcp_wrappers=YES

注意:配置完成之后,(重启)服务,如果服务异常,请输入(查看状态命令)服务,服务具体错误有提示。

例如下图,错误提示信息给出来了,你查看错误发现你输入的信息也对,为啥有这个提示,

请相信你的PC,你输入有问题,看下你的空格,空格,空格

如何在CentOS 7上使用vsftpd设置ftp服务器


我的配置文件

[root@centos----20G ~]# vi /etc/vsftpd/vsftpd.conf

#  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. for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf. 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=YES
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 . You may wish to change this to ,
# if your users expect that ( is used by most other ftpd's)
local_umask=
#
# 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=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# 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 (ftp-data).
connect_from_port_20=YES
#
# 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
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=
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=
#
# 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() 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.
ftpd_banner=sopcce.com welcome to 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=NO
#
# 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=YES
tcp_wrappers=YES #ADD
userlist_file=/etc/vsftpd/user_list
userlist_deny=YES
user_sub_token=$USER
local_root=/ allow_writeable_chroot=YES pasv_min_port=
pasv_max_port=

3、设置root 账号登录权限

编辑一下文件,重启服务查看状态。

vi  /etc/vsftpd/ftpusers  注释掉 #root
vi /etc/vsftpd/user_list 注释掉 #root
vi /etc/vsftpd/vsftpd.conf write_enable=YES

具体操作如下

[root@centos001 ~]# cd /etc/vsftpd
[root@centos001 vsftpd]# ls
ftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh
[root@centos001 vsftpd]# vi user_list
[root@centos001 vsftpd]# vi ftpusers
[root@centos001 vsftpd]# systemctl restart vsftpd.service
[root@centos001 vsftpd]# systemctl status vsftpd.service
● vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2019-05-09 00:08:15 CST; 7s ago
Process: 10007 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
Main PID: 10008 (vsftpd)
CGroup: /system.slice/vsftpd.service
└─10008 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf May 09 00:08:15 centos001 systemd[1]: Stopping Vsftpd ftp daemon...
May 09 00:08:15 centos001 systemd[1]: Stopped Vsftpd ftp daemon.
May 09 00:08:15 centos001 systemd[1]: Starting Vsftpd ftp daemon...
May 09 00:08:15 centos001 systemd[1]: Started Vsftpd ftp daemon.
[root@centos001 vsftpd]#

4、安装FTP,测试

输入、

yum install ftp

具体操作如下

[root@centos----20G ~]# yum install ftp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package ftp.x86_64 :0.17-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved ===============================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================
Installing:
ftp x86_64 0.17-.el7 base k Transaction Summary
===============================================================================================================================================
Install Package Total download size: k
Installed size: k
Is this ok [y/d/N]: y
Downloading packages:
ftp-0.17-.el7.x86_64.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : ftp-0.17-.el7.x86_64 /
Verifying : ftp-0.17-.el7.x86_64 / Installed:
ftp.x86_64 :0.17-.el7 Complete!
[root@centos----20G ~]#

测试本地FTP

[root@centos----20G ~]# ftp
ftp> open 127.0.0.1
Connected to 127.0.0.1 (127.0.0.1).
welcome to ... ftp vsftpd server.
Name (127.0.0.1:root): root
Permission denied.
Login failed.
ftp> quit
Goodbye.

五、配置vsftpd 创建FTP用户

为了测试我们的FTP服务器,我们将创建一个新用户。

如果您已经拥有要授予FTP访问权限的用户,请跳过第1步。
如果在配置文件中设置allow_writeable_chroot = YES,请跳过第3步。
创建一个名为sopftpuser的新用户:

1、创建一个名为sopftpuser的新用户,接下来,设置用户密码

sudo adduser sopftpuser
sudo passwd sopftpuser

2、将用户添加到允许的FTP用户列表中

 echo "sopftpuser" | sudo tee -a /etc/vsftpd/user_list

3、创建FTP目录树并设置正确的权限

 sudo mkdir -p /home/sopftpuser/ftp/

 sudo chmod  /home/sopftpuser/ftp

 sudo chmod  /home/sopftpuser/ftp/

 sudo chown -R sopftpuser: /home/sopftpuser/ftp

如上一节所述,用户可以将其文件上传到ftp / upload目录。

此时,您的FTP服务器功能齐全,您应该可以使用任何可配置为使用TLS加密的FTP客户端(如FileZilla)连接到您的服务器

[root@centos001 ~]# sudo adduser sopftpuser
[root@centos001 ~]# sudo passwd sopftpuser
Changing password for user sopftpuser.
New password:
BAD PASSWORD: The password is shorter than characters
Retype new password:
Sorry, passwords do not match.
New password:
BAD PASSWORD: The password fails the dictionary check - it does not contain enough DIFFERENT characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@centos001 ~]# echo "sopftpuser" | sudo tee -a /etc/vsftpd/user_list
sopftpuser
[root@centos001 ~]# sudo mkdir -p /home/sopftpuser/ftp/
[root@centos001 ~]# sudo chmod /home/sopftpuser/ftp
[root@centos001 ~]# sudo chmod /home/sopftpuser/ftp/upload
chmod: cannot access ‘/home/sopftpuser/ftp/upload’: No such file or directory
[root@centos001 ~]# sudo chmod /home/sopftpuser/ftp
[root@centos001 ~]# sudo chown -R sopftpuser: /home/sopftpuser/ftp
[root@centos001 ~]#

六、卸载(出错了,你就卸载了在重新安装,或者修改你的配置文件,此操作我做了多次,毕竟是萌新)

如果服务器上安装了vsftpd,配置出错需要卸载vsftpd

rpm -aq vsftpd

卸载vsftpd

rpm -e vsftpd-3.0.

#用rpm -e 查找结果 进行删除就ok了。

 warning: /etc/vsftpd/user_list saved as /etc/vsftpd/user_list.rpmsave
 warning: /etc/vsftpd/ftpusers saved as /etc/vsftpd/ftpusers.rpmsave #删除时将备份vsftp的用户列表文件。

如何在CentOS 7上使用vsftpd设置ftp服务器

七、结论

您学习了如何在CentOS 7系统上安装和配置安全,输入用户名和密码,登录FTP

如何在CentOS 7上使用vsftpd设置ftp服务器

八、相关资料

》查看https://linuxize.com/post/how-to-setup-ftp-server-with-vsftpd-on-centos-7/,本文大部分是参看它的介绍,

但是在此基础上做了增加,但是其中遇到了很多的坑,哎

》查看https://www.cnblogs.com/sopcce/p/10743359.html 本文介绍了配置文件,

包括特别多,对ftp 访问的授权,访问的目录等,还在慢慢看中

解决:

setenforce: SELinux is disabled

那么说明selinux已经被彻底的关闭了

如果需要重新开启selinux,请按下面步骤:

vi /etc/selinux/config

更改为:SELINUX=1

必须重启linux,不重启是没办法立刻开启selinux的

关闭

1 命令查看出selinux的状态

sestatus -v

2 临时关闭 selinux

setenforce 0

3 永久关闭selinux

vi /etc/sysconfig/selinux

把里边的一行改为

SELINUX=disabled

setenforce 1 设置SELinux 成为enforcing模式

setenforce 0 设置SELinux 成为permissive模式

如果要彻底禁用SELinux 需要在/etc/sysconfig/selinux中设置参数selinux=0

更新日期:2019-04-21

vi