Linux_FTP服务器

简介:

FTP

FTP(File Transfer Protocol文件传输协议),用于Internet上的控制文件的双向传输。同时,它也是一个Application。基于不同的操作系统有不同的FTP应用程序,而所有这些应用程序都遵守同一种FTP协议以传输文件。在FTP的使用当中,用户经常遇到两个概念:”下载”(Download)和”上传”(Upload)。”下载”文件就是从远程主机拷贝文件至自己的计算机上;”上传”文件就是将文件从自己的计算机中拷贝至远程主机上。用Internet语言来说,用户可通过FTPClient向(从)FTPServer上传(下载)文件。 
FTP也是一个C/S架构。用户通过一个支持FTP协议的客户机程序,连接到在远程主机上的FTP服务器程序。用户通过客户机程序向服务器程序发出命令,服务器程序执行用户所发出的命令,并将执行的结果返回到客户机。比如说,用户发出一条命令,要求服务器向用户传送某一个文件的一份拷贝,服务器会响应这条命令,将指定文件送至用户的机器上。客户机程序代表用户接收到这个文件,将其存放在用户目录中。 
TCP/IP协议中,FTP标准命令TCP端口号为21,Port方式数据端口为20。FTP的任务是从一台计算机将文件传送到另一台计算机,不受操作系统的限制。 
FTPServer访问权限类型:匿名用户、虚拟用户、本地用户

FTP Server

FTPServer Support anonymous userlocal userVirtual user between share date. 
Attention:But in the same computer, the virtual user and local user config can’t exist at the same time. 
ServicePort: 
a. TCP 21:Control commands transmission port. 
b. TCP 20:Date transmission port. 
Software:vsftpd 
serviceName:vsftpd 
User permission control file: 
a. /etc/vsftpd/ftpuser –> deny login user,have higher priority 
b. /etc/vsftpd/user_list –> only allow login user

FTP configuration

Global config

    listen=YES     #Use independent type to Listen into service
    listen_address=ip     #Assign listenIP
    listen_port=21
    ftp_date_port=20
    write_enable=YES      #whether upload
    download_enable=YES    #whether download
    userlist_enable=YES   #whether use user_list file
    max_clients=0   #client connect conunt,0 measing is no limit.
    pasv_enable=YES
    pasv_min_port=portNumber   #passivity(PASV) min float portNumber,FTPServer will proactive(PORT) use TCP20 port to connection client's PASV port(1025-65535).On the contrary, too.
    pasv_max_poer=portNumber
    data_connection_timeout=120 #connection timeout
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

Anonymous user FTP Config

vim /etc/vsftpd/vsftpd.conf

anonymous_enable=YES    #open anonymous login permissions
anon_umask=022       #anonymous user upload file's umask and anonymous user use ftp account to upload the file, use other account to download file. Anonymous user default support download file.
anon_root=/var/ftp   #root directory after login --> the root directory cannot own 'rwx' permission and both owners and owning group are 'root'.
anon_upload_enable=YES   #allow upload file
anon_mkdir_wirte_enable=YES   #allow mkdir
anon_other_write_enable=YES    #allow edit,delete,move the file
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Attention:要实现匿名的下载,修改,删除,创建时,不可以修改FTP根目录的权限和属主,但是可以在根目录下创建AnonymousDir,并将其属主:属组修改为ftp:root,目录权限为757(出于安全的考虑)。

Virtual user FTP

step1. Create virtual user register DB file.

 touch vuser.list
  • 1
  • 1

vim vuser.list

userName
userPasswd 
  • 1
  • 2
  • 1
  • 2

step2. Convert the format of userDB file to Berkey DB.

db_load -T -t hash -f vuser.list vuser.db
chmod 600 vuser.*
  • 1
  • 2
  • 1
  • 2

step3. Create FTP root file also virtual user mapped as system user.

useradd -d /var/ftp/soft -s /sbin/nologin virtual
        -d  #specify virtual's homeDirectory
        -S  #specify virtual's shell
        virtual  #All virtual user will mapped as system user when they login.
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

虚拟用户上传时使用virtual用户的身份来进行,其宿主目录为/var/ftp/soft

chmod 755 /var/ftp/soft   #Home directory permission decided what can the virtual user do in the FTP share home directory.
  • 1
  • 1

step4. Create PAM authentication file to support virtual user login.(PAM Pluggable authentication modules) 
vim /etc/pam.d/vsftpd.vu

auth required pam.userdb.so db=/etc/vsftpd/vuser   #identity authentication specify vuser.db file
account required pam.userdb.so db=/etc/vsftpd/vuser  #identity verification
  • 1
  • 2
  • 1
  • 2

step5. Edit the vsftp.conf file

guest_enable=YES
guest_username=virtual   #specify virtual user mapped system user
pam_service_name=vsftpd.vu   #PAM authentication file,localUser's PAM is vsftpd. So localUser and virtualUser can't exist at the same time.
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

step6. Set the specific permission for virtualUser. 
vim /etc/vsftpd/vsftpd.conf

user_config_dir=/etc/vsftpd/vusers_dir
mkdir /etc/vsftpd/vuser_dir
  • 1
  • 2
  • 1
  • 2

vim /etc/vsftpd/vuser_dir/deradm

anon_ipload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
local_eoor=/var/market  #specify virtual user home directory.
Attention:If virtual user want to get the rwx permission in directory, we can set permission of 757 to the directory.Because the virtual user use the O(other)identity to access the directory.And we could be change the ownUser to ftp.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

Local user FTP

Edit the config file 
vim /etc/vsftpd/vsftpd.conf

local_enable=YES
local_root=/var/ftp
chroot_local_user=yes   #localUser's home directory limit
chroot_list_enable=yes
chroot_list_file=/etc/vsftpd/chroot_list


转载:http://blog.csdn.net/jmilk/article/details/50184877

目录
相关文章
|
14天前
|
运维 监控 Linux
推荐几个不错的 Linux 服务器管理工具
推荐几个不错的 Linux 服务器管理工具
|
24天前
|
安全 编译器 Linux
深入解析与防范:基于缓冲区溢出的FTP服务器攻击及调用计算器示例
本文深入解析了利用缓冲区溢出漏洞对FTP服务器进行远程攻击的技术,通过分析FreeFlow FTP 1.75版本的漏洞,展示了如何通过构造过长的用户名触发缓冲区溢出并调用计算器(`calc.exe`)。文章详细介绍了攻击原理、关键代码组件及其实现步骤,并提出了有效的防范措施,如输入验证、编译器保护和安全编程语言的选择,以保障系统的安全性。环境搭建基于Windows XP SP3和Kali Linux,使用Metasploit Framework进行攻击演示。请注意,此内容仅用于教育和研究目的。
67 4
|
2月前
|
缓存 监控 Linux
Python 实时获取Linux服务器信息
Python 实时获取Linux服务器信息
W9
|
2月前
|
运维 关系型数据库 MySQL
轻松管理Linux服务器的5个优秀管理面板
Websoft9 应用管理平台,github 2k star 开源软件,既有200+的优秀开源软件商店,一键安装。又有可视化的Linux管理面板,文件、数据库、ssl证书方便快捷管理。
W9
130 1
|
2月前
|
缓存 Ubuntu Linux
Linux环境下测试服务器的DDR5内存性能
通过使用 `memtester`和 `sysbench`等工具,可以有效地测试Linux环境下服务器的DDR5内存性能。这些工具不仅可以评估内存的读写速度,还可以检测内存中的潜在问题,帮助确保系统的稳定性和性能。通过合理配置和使用这些工具,系统管理员可以深入了解服务器内存的性能状况,为系统优化提供数据支持。
58 4
|
2月前
|
NoSQL Linux PHP
如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤
本文介绍了如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤。接着,对比了两种常用的 PHP Redis 客户端扩展:PhpRedis 和 Predis,详细说明了它们的安装方法及优缺点。最后,提供了使用 PhpRedis 和 Predis 在 PHP 中连接 Redis 服务器及进行字符串、列表、集合和哈希等数据类型的基本操作示例。
86 4
|
3月前
|
监控 Linux Shell
|
2月前
|
运维 监控 安全
盘点Linux服务器运维管理面板
随着云计算和大数据技术的迅猛发展,Linux服务器在运维管理中扮演着越来越重要的角色。传统的Linux服务器管理方式已经无法满足现代企业的需求,因此,高效、安全、易用的运维管理面板应运而生。
|
3月前
|
监控 Java Linux
Linux系统之安装Ward服务器监控工具
【10月更文挑战第17天】Linux系统之安装Ward服务器监控工具
79 5
Linux系统之安装Ward服务器监控工具
|
2月前
|
运维 监控 Linux
服务器管理面板大盘点: 8款开源面板助你轻松管理Linux服务器
在数字化时代,服务器作为数据存储和计算的核心设备,其管理效率与安全性直接关系到业务的稳定性和可持续发展。随着技术的不断进步,开源社区涌现出众多服务器管理面板,这些工具以其强大的功能、灵活的配置和友好的用户界面,极大地简化了Linux服务器的管理工作。本文将详细介绍8款开源的服务器管理面板,包括Websoft9、宝塔、cPanel、1Panel等,旨在帮助运维人员更好地选择和使用这些工具,提升服务器管理效率。