CentOS 7 yum配置和vsftpd的安装配置

来源:互联网 发布:godaddy PHP创建 编辑:程序博客网 时间:2024/05/21 07:56

CentOS 7 yum配置和vsftpd的安装配置

  • 阿里云yum源的配置
  • yum安装vsftpd
  • firewall防火墙的配置

阿里云yum源的配置

备份系统yum源

mv /etc/yum.repos.d/CentOS-Base.repo  /etc/yum.repos.d/CentOS-Base.repo.backup

下载CentOS7阿里云源

wget http://mirrors.aliyun.com/repo/Centos-7.repo//移动到 etc下mv Centos-7.repo /etc/yum.repos.d/CentOS-Base.repo

创建缓存

yum makecache

vsftpd安装

yum安装vsftpd

yum -y install vsftpd

检查是否安装

 rpm -qa|grep vsftpd

创建ftp用户的目录

mkdir /ftphome

创建虚拟用户可以使用ftp不能登陆系统

usadd ftpuser -d /ftpfile -s /sbin/nologpasswd ftpuser//输入密码

修改ftphome权限并添加用户配置文件最后需要将配文件引用到ftp配置中

chown -R ftpuser.ftpuser /ftphomevim chroot_list :wq保存退出

修改selinux

vim /etc/selinux/config 修改 SELINUX=disable (setenfore 0//强制生效)

配置vsftpd.conf

vim /etc/vsftpd/vsftpd.conf 
local_root=/ftphome #chroot_local_user=YES anon_root=/ftphomeuse_localtime=YES#匿名#anonymous_enable=YESanonymous_enable=NOlocal_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_upload_enable=YES#anon_mkdir_write_enable=YESdirmessage_enable=YESxferlog_enable=YESconnect_from_port_20=YES#chown_uploads=YES#chown_username=whoeverxferlog_std_format=YES#xferlog_file=/var/log/xferlogxferlog_std_format=YES#ascii_upload_enable=YES#ascii_download_enable=YESftpd_banner=Welcome to FTP Serverchroot_local_user=NOchroot_list_enable=YESchroot_list_file=/etc/vsftpd/chroot_listlisten=YES#listen_ipv6=YESpam_service_name=vsftpduserlist_enable=YEStcp_wrappers=YES#pasv_enable=YESpasv_min_port=61001pasv_max_port=62000allow_writeable_chroot=YES

添加ftp开机自启

systemctl enable vsftpd.service

安装ftp客户端检验

yum -y install ftp

配置firewall防火墙

firewall常用命令

1、重启、关闭、开启firewalld.service服务service firewalld restart 重启service firewalld start 开启service firewalld stop 关闭2、查看firewall服务状态systemctl status firewall3、查看firewall的状态firewall-cmd --state4、查看防火墙规则firewall-cmd --list-all 

配置防火墙规则(两种方式)
令名方式

 vim /etc/firewalld/zones/public.xml
 <rule family="ipv4">    <port protocol="tcp" port="61001-62000"/>    <accept/>  </rule>  <rule family="ipv4">    <port protocol="tcp" port="21"/>    <accept/>  </rule>  <rule family="ipv4">    <port protocol="tcp" port="20"/>    <accept/>  </rule>

图形方式

yum -y install firewall-config//安装成功后使用下面的命令在弹出界面进行配置firewall-config

熟悉iptables的可以按照下面的方式配置
由于centos7 自带的是firewall没有iptables我们要禁用firewall安装配置配置iptables
禁用firewall

systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动

安装iptables

#先检查是否安装了iptablesservice iptables status#安装iptablesyum install -y iptables#升级iptablesyum update iptables #安装iptables-servicesyum install iptables-services 

配置iptables

vim /etc/sysconfig/iptables
-A INPUT  -p TCP --dport 61001:62000 -j ACCEPT  -A OUTPUT -p TCP --sport 61001:62000 -j ACCEPT -A INPUT  -p TCP --dport 20 -j ACCEPT   -A OUTPUT -p TCP --sport 20 -j ACCEPT-A INPUT  -p TCP --dport 21 -j ACCEPT-A OUTPUT -p TCP --sport 21 -j ACCEPT

修改iptable开机启动

systemctl enable iptables.service #iptables开机启动

重新启动机器(修改了selinux重新启动让配置生效)

常用命令systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动systemctl stop iptables.service #停止iptablessystemctl disable iptables.service #禁止iptables开机启动systemctl restart vsftpd.service #重新启动ftp服务