Forward from: https://linuxconfig.org/how-to-setup-vsftpd-ftp-file-server-on-redhat-7-linux

How to setup vsftpd FTP file Server on Redhat 7 Linux

 

In this short config we will install FTP file Server on RHEL7 Linux using vsftpd. We will stick to the default vsftpd configuration which enables user accounts on our existing RHEL7 Linux system to login via FTP from a remote location, list and transfer files. Let's begin by the installation:

To install FTP server on Redhat 7 Linux we can use either tftp-server or vsftpd daemon. In this guide we use vsftpd:

[root@rhel7 ~]# yum install vsftpd

Next, we can start the vsftpd service by using a service command:

[root@rhel7 ~]# service vsftpd start
Redirecting to /bin/systemctl start vsftpd.service

To make the FTP service startup persistent after system reboot use:

[root@rhel7 ~]# systemctl enable vsftpd
ln -s '/usr/lib/systemd/system/vsftpd.service' '/etc/systemd/system/multi-user.target.wants/vsftpd.service'

Check and see whether port 21 is open. Do not worry if you do not see IPv4 of this port open as its IPv6 bind.

[root@rhel7 ~]# netstat -tanp | grep LISTEN

We also need to open firewall port otherwise we will see a following error message when we try to connect:

ftp: connect: No route to host
ftp>

To open a port 21 on Redhat 7 linux use the following commands. The port we remain open to public even after system restart:

[root@rhel7 ~]# firewall-cmd --zone=public --add-port=21/tcp --permanent
success
[root@rhel7 ~]# firewall-cmd --reload
success

At this point we should be able to connect from a remote host where the IP address of our FTP service is 10.1.1.110:

$ ftp 10.1.1.110
Connected to 10.1.1.110 (10.1.1.110).
220 (vsFTPd 3.0.2)
Name (10.1.1.110:lrendek): rhel7
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

The next configuration we need to perform is to enable iptables module ip_conntrack_ftp otherwise we will see a following error message query our FTP server after successful login:

ftp> ls
227 Entering Passive Mode (10,1,1,110,166,190).
ftp: connect: No route to host
ftp>

As a temporary solution we use modprobe to load the ip_conntrack_ftp module:

[root@rhel7 ~]# modprobe ip_conntrack_ftp

See this page for a more permanent solution on how to load ip_conntrack_ftp module after reboot.

The last configuration we need to perform is to enable selinux FTP context for user directories currently on the system otherwise we will not be able to read/write or transfer any files between FTP server and FTP client:

230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> put ftp-test.txt
local: ftp-test.txt remote: ftp-test.txt
227 Entering Passive Mode (10,1,1,110,125,139).
553 Could not create file.

To enable selinux FTP home directory context to allow read and write commands. For this we use setsebool command:

[root@rhel7 ~]# setsebool -P ftp_home_dir=1

The above will set selinux FTP home directory context permanently -P after reboot.

ftp> put ftp-test.txt
local: ftp-test.txt remote: ftp-test.txt
227 Entering Passive Mode (10,1,1,110,174,219).
150 Ok to send data.
226 Transfer complete.

Now you have your FTP server setup. For more configuration options see the main vsftpd FTP server configuration file/etc/vsftpd/vsftpd.conf. When making a changes to the configuration file make sure to apply them by restarting FTP service:

[root@rhel7 ~]# service vsftpd restart
Redirecting to /bin/systemctl restart vsftpd.service

最新文章

  1. LinQ C#防注入式攻击实例代码
  2. Python函数参数默认值的陷阱和原理深究"
  3. ACM: The Suspects-并查集-解题报告
  4. Diagramming for WinForms 的安装和配置
  5. 用户控件UserControl图片资源定位(一)---Xaml引用图片
  6. JS全局函数parseInt和parseFloat
  7. C#字符串的比较
  8. SQL Server 2008数据库的一些基本概念 区、页、行
  9. iOS:编译错误 linker command failed with exit code 1 (use -v to see invocation)
  10. Instll meld in windows
  11. Delphi水晶横向竖向打印
  12. Excel 复制Sql查询结果错位
  13. 8636 跳格子(dfs+记忆化搜索)
  14. C语言程序设计第一次作业1
  15. 2、Linux安装jmeter
  16. Linux 下 zip 文件解压中文乱码
  17. C++学习(三十)(C语言部分)之 栈和队列
  18. linux tomcat启动后无法访问
  19. SQL语句之 多表管理
  20. 如何用xmlspy将xml文档生成xsd文件

热门文章

  1. There is insufficient system memory to run this query 错误
  2. 不死僵尸木马lpt7.asp.asp与lpt5.cnzzz.asp的删除方法
  3. 从零自学Hadoop(13):Hadoop命令下
  4. WPF 依赖属性
  5. 学习大神笔记之“MyBatis学习总结(三)”
  6. WinCE常用调试工具汇总
  7. java读取excel文件
  8. 如何进行安全测试-XSS篇
  9. 分页ajax+springmvc的简单实现
  10. Java8并发教程:Threads和Executors