本文共 5178 字,大约阅读时间需要 17 分钟。
centOS7安装FTP
1 以管理员运行:yum install vsftpd#安装ftp
2 chkconfig vsftpd on#设置开机启动 3 service vsftpd start #启动ftp服务 4 yum -y install ftp #安装组件,5创建ftp根目录:mkdir -p /ftpserver
ftp localhost #测试登陆,输入用户名ftp,密码随便(因为默认是允许匿名的)登录成功,就代表ftp服务可用了。但是,外网是访问不了的,所以还要继续配置。 vim /etc/sysconfig/iptables #找到一行22 -j ACCEPT 把它复制一行到下面,把端口号22改成21,保存退出 service iptables restart #重启防火墙 vim /etc/vsftpd/vsftpd.conf #去掉两行注释 #chroot_list_enable=YES 和 #chroot_list_file=/etc/vsftpd.chroot_list 的#号 service vsftpd restart #重启ftp服务 useradd -d /www aaa #新建用户aaa,并指定/www为访问目录 passwd aaa #给用户aaa设置密码 usermod -d /www/app aaa #修改aaa的主目录为/www/appvsftpd-3.0.2-10.el7.x86_64 (显示也就安装成功了!)
如果没有则安装vsftpd
[root@localhost ~]# yum install -y vsftpd1
安装完成后可以查看到安装的目录
[root@localhost ~]# whereis vsftpd1
vsftpd: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz
查看vsftpd服务的状态
[root@localhost ~]# systemctl status vsftpd.service1
● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled) Active: active (running) since 三 2017-07-05 14:29:53 CST; 3s ago Process: 3951 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS) Main PID: 3953 (vsftpd) CGroup: /system.slice/vsftpd.service ├─3953 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf ├─3963 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf └─3964 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf7月 05 14:29:53 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon…
7月 05 14:29:53 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.开启vsftpd服务
[root@localhost ~]# systemctl start vsftpd.service1
设置vsftpd服务开机自启
[root@localhost ~]# vi /etc/vsftpd/vsftpd.conf
1 anonymous_enable=YES
2local_enable=YES
3anon_umask=077
4 chroot_local_user=NO
5 chroot_list_enable=YES
6 chroot_list_file=/var/public_root
7 listen_port=1802
8 pasv_enable=NO
9 pasv_min_port=3000
10 pasv_max_port=30999
11 pasv_promiscuous=YES
12pasv_service_name=vsftpd
13userlist_enable=NO
3、添加FTP账户
这里设置的账户名为“test”,密码为“123456”
[root@localhost ~]# useradd test -s /sbin/nologin
[root@localhost ~]# passwd 123456124、编辑user_list文件,允许test用户访问FTP
[root@localhost ~]# vi /etc/vsftpd/user_list
# vsftpd userlist # If userlist_deny=NO, only allow users in this file # If userlist_deny=YES (default), never allow users in this file, and # do not even prompt for a password. # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers # for users that are denied. root bin daemon adm lp sync shutdown halt mail news uucp operator games nobody test ~ ~ ~ ~ "/etc/vsftpd/user_list" 21L, 366C12345678910111213141516171819202122232425262728295、建根目录,并设置访问权限
[root@localhost ~]# mkdir /var/public_root
[root@localhost ~]# chown -R test /var/public_root [root@localhost ~]# chmod -R 777 /var/public_root123
5 ftp localhost #测试登陆,输入用户名ftp,密码随便(因为默认是允许匿名的)登录成功,就代表ftp服务可用了。但是,外网是访问不了的,所以还要继续配置。
---------------------
另一种FTP
1 yum install vsftpd
2 systemctl start vsftpd.service 3 systemctl enable vsftpd.service3 yum -y install ftp
4ftp localhost ftp>exit 退出2 vim /etc/vsftpd/vstfpd.conf
配置: anonymous_enable=NO重起
systemctl restart vsftpd.service 1 设置 anonymous_enable=NO2 chroot_local_user=YES
chroot_list_enable=YES 删除注释3 allow_writeable_chroot=YES
第一、配置文件修改vi /etc/vsftpd/vsftpd.conf
首先需要在vsftpd配置文件中添加:listen_port=1802
pasv_enable=YES pasv_min_port=30000 pasv_max_port=30999 pasv_promiscuous=YES ftpd_banner=Welcome to https://www.itbulu.com FTP service listen_port端口我们可以自己设置。pasv_min_port和pasv_max_port也是随意设置的,后面我们开启防火墙的时候对应就可以了。第二、修改services文件
vi /etc/services
如果我们不方便用VI工具的话就下载到本地,因为文件比较多。直接将两处的FTP参数后面21修改成我们上面设置的端口。修改services文件
第三、端口防火墙设置
上面我们设置了新的端口,如果有iptables设置的,我们需要开放端口。
vi /etc/sysconfig/iptables
在合适的位置添加:-A INPUT -p tcp -m state --state NEW -m tcp --dport 30000:30999 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1802 -j ACCEPT 保存重启iptablesservice iptables restart
第四、重启vsftpd检测service vsftpd restart
groupadd ftpgroups
mkdir /home/ftp useradd -d /home/ftp -g ftpgroups shumeigang 出错 不从skel 目录里向其中复制任何文件 usermod -s /sbin/nologin shumeignag4CentOS7
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)1.关闭firewall
[root@localhost ~]# systemctl stop firewalld.service //停止firewall
[root@localhost ~]# systemctl disable firewalld.service //禁止firewall开机启动centOS 6.5关闭防火墙步骤
关闭命令: service iptables stop 永久关闭防火墙:chkconfig iptables off 两个命令同时运行,运行完成后查看防火墙关闭状态 service iptables status2.安装iptables
[root@localhost ~]# yum install iptables-services //安装
[root@localhost ~]# systemctl restart iptables.service #重启防火墙使配置生效
[root@localhost ~]# systemctl enable iptables.service #设置防火墙开机启动
[root@localhost ~]# systemctl disable iptables.service #禁止防火墙开机启动
passwd shumeigang
systemctl restart vsftpd.service
转载地址:http://mlfni.baihongyu.com/