Linux FTP服务器搭建
实验环境:一台server服务器,一台client客户端
先在服务器创建几个常用用户,以便后期通过FTP访问服务器使用:
1.批量创建用户
[root@linzefeng ~]# mkdir bin
[root@linzefeng ~]# ll
total 12
-rw-------. 1 root root 3361 Mar 5 04:11 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Apr 2 04:45 bin
-rw-r--r--. 1 root root 1826 Mar 19 21:06 ktest
-rw-------. 1 root root 2044 Mar 5 04:11 original-ks.cfg
[root@linzefeng ~]# vim useradd.sh
然后进去编辑vim useradd.sh
#!/bin/bash
groupadd testgroup
for username in linzefeng1 linzefeng2 linzefeng3 linzedfeng4 linzefeng5
do
useradd -G testgroup $username
echo "123456" |passwd --stdin $username
done
执行结果如下:
退出授予权限;
[root@linzefeng ~]# chmod +x ./useradd.sh
[root@linzefeng ~]# ./useradd.sh
Changing password for user linzefeng1.
passwd: all authentication tokens updated successfully.
Changing password for user linzefeng2.
passwd: all authentication tokens updated successfully.
Changing password for user linzefeng3.
passwd: all authentication tokens updated successfully.
Changing password for user linzedfeng4.
passwd: all authentication tokens updated successfully.
Changing password for user linzefeng5.
passwd: all authentication tokens updated successfully.
2.安装FTP服务器
yum install -y vsftpd
此时,关掉防火墙和SELinux,然后进行客户端访问
使用被动模式进行访问:
首先配置防火墙
systemctl start firewalld.service
#防火墙添加永久用过FTP服务
firewall-cmd --add-service=ftp --permanent
#重启防火墙
[root@linzefeng ~]# firewall-cmd --reload
success
#重启NetworkManager.service
systemctl restart NetworkManager.service
然后从客户端再次进行访问ftp
这个是被动模式访问FTP,做之前记得两边的防火墙都关掉