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

目录
相关文章
|
4月前
|
弹性计算 安全 Linux
阿里云服务器ECS安装宝塔Linux面板、安装网站(新手图文教程)
本教程详解如何在阿里云服务器上安装宝塔Linux面板,涵盖ECS服务器手动安装步骤,包括系统准备、远程连接、安装命令执行、端口开放及LNMP环境部署,手把手引导用户快速搭建网站环境。
|
9月前
|
安全 Java Linux
Websoft9:为开发者打造的高效 Linux 服务器面板
Websoft9 是一款以开源应用部署与管理为核心的服务器面板,采用“环境即服务”模式。它通过运行环境标准化、自动化配置、安全融合和资源管理四个方面实现平台与环境的深度协同。支持多语言框架预集成、云原生组件整合,提供 200+ 应用模板一键部署,并具备全流程安全防护和统一资源监控能力,助力开发者高效管理和扩展应用环境。
277 0
|
6月前
|
Linux 网络安全 数据安全/隐私保护
使用Linux系统的mount命令挂载远程服务器的文件夹。
如此一来,你就完成了一次从你的Linux发车站到远程服务器文件夹的有趣旅行。在这个技术之旅中,你既探索了新地方,也学到了如何桥接不同系统之间的距离。
1119 21
|
5月前
|
Java Linux 网络安全
Linux云端服务器上部署Spring Boot应用的教程。
此流程涉及Linux命令行操作、系统服务管理及网络安全知识,需要管理员权限以进行配置和服务管理。务必在一个测试环境中验证所有步骤,确保一切配置正确无误后,再将应用部署到生产环境中。也可以使用如Ansible、Chef等配置管理工具来自动化部署过程,提升效率和可靠性。
581 13
|
5月前
|
监控 Linux 网络安全
FinalShell SSH工具下载,服务器管理,远程桌面加速软件,支持Windows,macOS,Linux
FinalShell是一款国人开发的多平台SSH客户端工具,支持Windows、Mac OS X和Linux系统。它提供一体化服务器管理功能,支持shell和sftp同屏显示,命令自动提示,操作便捷。软件还具备加速功能,提升访问服务器速度,适合普通用户和专业人士使用。
1563 0
|
5月前
|
存储 安全 Linux
Linux服务器上安装配置GitLab的步骤。
按照以上步骤,一个基础的GitLab服务应该运行并可以使用。记得定期检查GitLab官方文档,因为GitLab的安装和配置步骤可能随着新版本而变化。
463 0
|
7月前
|
Ubuntu Linux 网络安全
在Linux云服务器上限制特定IP进行SSH远程连接的设置
温馨提示,修改iptables规则时要格外小心,否则可能导致无法远程访问你的服务器。最好在掌握足够技术知识和理解清楚操作含义之后再进行。另外,在已经配置了防火墙的情况下,例如ufw(Ubuntu Firewall)或firewalld,需要按照相应的防火墙的规则来设置。
393 24
|
7月前
|
存储 安全 Ubuntu
从Linux到Windows:阿里云服务器系统镜像适配场景与选择参考
阿里云为用户提供了丰富多样的服务器操作系统选择,以满足不同场景下的应用需求。目前,云服务器的操作系统镜像主要分为公共镜像、自定义镜像、共享镜像、镜像市场和社区镜像五大类。以下是对这些镜像类型的详细介绍及选择云服务器系统时需要考虑的因素,以供参考。
|
6月前
|
Linux
Linux下版本控制器(SVN) -服务器端环境搭建步骤
Linux下版本控制器(SVN) -服务器端环境搭建步骤
287 0
Linux下版本控制器(SVN) -服务器端环境搭建步骤
|
8月前
|
安全 Linux
阿里云linux服务器使用脚本通过安全组屏蔽异常海外访问ip
公网网站可能会遭受黑客攻击导致访问异常,使用此脚本可以屏蔽掉异常IP 恢复访问。也可自行设置定时任务定期检测屏蔽。
641 28