FTP工作原理

FTP Transfer Protocol 传输协议的缩写。

FTP会话包含了两个通道,一个叫控制通道,一个叫数据通道。

控制通道:控制通道是和FTP服务器进行沟通的通道,链接FTP,发送FTP指令都是通过控制通道来完成的。
数据通道:数据通道是和FTP服务器进行文件传输或者列表的通道。

FTP协议中,控制连接均有客户端发起,而数据链接有两种方式:PORT方式和PASV方式

PORT模式(主动方式)

PORT模式简历数据传输通道是由服务器端发起的,服务器使用20端口链接客户端的某一个大于1024的端口。
FTP客户端首先和FTP 服务端的tcp 21端口建立连接,通过这个通道发送命令,客户端需要接受数据的时候在这个通道上发送PORT命令。PORT命令包含了客户端用什么端口(大于1024 的端口)接受数据,在传送数据的时候,服务器端通过自己的TCP 20 端口发送数据,FTP 服务端必须和客户端建立一个新的链接来传送数据。

客户端使用1024以上的端口链接服务器的21号端口,并且会实现开启一个1024+N的dua扣准备让服务器来链接,服务器得知客户端准备的端口后,用20号端口与客户端链接,其中21号端口称为链接链路,20号端口称为数据链路,创建数据链路时server端处于主动链接客户端的状态,称为:主动传输模式。

PASV模式(被动方式)

PASV模式中,数据传输的通道的建立是由FTP客户端发起的,他是用一个大于1024的端口链接服务器的1024以上的某一个端口。在建立控制通道的时候和PORT模式类似,当客户端通过这个通道发送PASV命令的时候,FTP server打开一个大于1024的随机端口并进行数据的传输,这个时候FTP server 不再需要建立一个新的和客户端之间的链接传送数据。

客户端使用1024以上的端口链接服务器端的21端口,服务器接到链接请求后,开启一个1024+M的端口,等待客户端来链接,在通知客户端这个等待连接的端口号是1024+M,客户端接到服务器端的信息后,开启新的一个1024+N的端口与1024+M进行链接,其中21号端口为连接链路,1024+M端口为数据链路,创建数据链接时,server端处于被客户端链接的状态,所以称为:被动传输模式。

[root@localhost ~]# cat /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES              # 匿名用户是否可以访问FTP
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES                   # 本地用户是否登录
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES                   # 允许FTP的写指令
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022                    # 本地用户建立文件的权限
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#anon_upload_enable=YES             # 允许匿名用户创建文件
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES        # 允许匿名用户创建新目录
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES                   # 使用日志功能
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES              # 主动模式传输使用20端口
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog        # 日志文件位置
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES                # 使用标准模式
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600             # 空闲链接超时
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120           # 数据传输超时
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=NO
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=YESpam_service_name=vsftpd              # 定义PAM所使用的名称
userlist_enable=YES                  # user_list文件有效,
tcp_wrappers=YES                     # 开启tcp_wrappers支持
[root@localhost ~]# 

FTP本地用户访问

首先安装ftp:yum install ftp ,,,然后通过ftp即可在本地访问

首先确保下面三项为YES

anonymous_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES

[root@localhost ~]# systemctl start vsftpd.service
[root@localhost ~]# systemctl status vsftpd.service
● vsftpd.service - Vsftpd ftp daemonLoaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)Active: active (running) since 三 2018-09-12 11:12:50 CST; 1s agoProcess: 57386 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)Main PID: 57388 (vsftpd)CGroup: /system.slice/vsftpd.service└─57388 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf9月 12 11:12:49 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon...
9月 12 11:12:50 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.
[root@localhost ~]# 

NFS服务器

NFS最初是由SUN公司开发的,目的就是在计算机不同操作系统之间可以彼此共享文件,NFS配置简单,快捷。客户端可以通过mount挂载之后像使用本地文件系统一样来只用远端共享目录。

在centos 7 上搭建NFS服务器比以往其实更加简单,卸掉了protmap服务,而是用rpcbind服务。

NFS服务器实现共享

/etc/exports 文件指定了那个文件系统的NFS应该输出(有时候也可以称之为“共享”)

/etc/exports 里面每行指定一个输出的文件系统和那些机器可以访问该文件系统。

在指定机器访问权限的同时,访问选项开关也可以被指定。

/ect/export 格式:

共享目录  主机1或ip1(选项1,选项2) 主机2或ip2(选项3,选项4)

主机名称格式:

单个主机/IP:station1.uplooking.com 192.168.1.1
IP网络: 192.168.1.0/255.255.255.0 172.16.1.0/15
通配符: *.uplooking.com

一般选项:

ro :read only
rw :允许nfs read write 请求
sync:同步存储后回应请求
async:在同步之前回应请求

用户ID映射:

root_squash :映射uid/gid 0 到匿名 uid/gid
no_root_squash: 关闭root squashing
all_squash:映射所有的uid/gid到匿名的uid/gid
anonuid and anongid:映射uid/gid到指定的uid/gid

exportfs 命令用来管理当前NFS共享的文件系统列表。这个列表保存在一个单独的文件/var/lib/nfs/etab中,当远端主机要求对一个文件系统树加载并访问时由mountd读取,列表中活动的一部分也保存在内核共享表中。通常etab在执行exportfs -a。的时候,根据/etc/exports中定义的共享列表来初始化。但是,管理员可以选择添加或者删除独立的文件系统,不必修改/etc/exports,只要执行exportfs就可以了

-a:全部挂载(或卸载) /etc/exports 文件内的设定。
-r :重新挂载/etc/exports中的设置,此外同步更新/etc/exports以及/var/lib/nfs/etab中的内容
-u:卸载某一目录
-v:在export时将共享的目录显示在屏幕上

[root@localhost ~]# exportfs -rv       # 全部重新export一次
[root@localhost ~]# exportfs -au       # 全部卸载
[root@localhost ~]# 

。。。更多请移驾百度。。。

Samba服务器

Samba,是一种自由软件,用来让Unix系列的操作系统与微软Windows操作系统的SMB/CIFS网络协议做联结。

应用环境:

文件和打印机共享:文件和打印机共享是Samba的主要功能,SMB进程实现资源的共享,将文件和打印机发布到网络之中,以供用户可以访问。
身份验证和权限设置:smbd服务支持user mode和domain mode等身份验证和权限设置模式,通过加密方式可以保护共享的文件和打印机。
名称解析:Samba通过nmbd服务可以搭建NBNS服务器,提供名称解析,将计算机的NetBIOS名解析为IP地址。
浏览服务:局域网中,Samba服务器可以成为贝蒂主浏览服务器(LMB),保存可用资源列表,当使用客户端访问Windows网上邻居时,会提供浏览器列表,显示共享目录,打印机等资源

更多请百度。。等用到了再补充。。

转载于:https://www.cnblogs.com/52-qq/p/9634059.html

服务管理-文件服务器相关推荐

  1. 文件服务器磁盘配额管理,文件服务器磁盘配额的管理.doc

    配额管理 Windows Server 203 R2"文件服务器"的"配额管理"包括如下功能: (1)通过创建配额来限制允许卷或文件夹使用的空间,并在接近或达到 ...

  2. 文件服务器磁盘配额管理,文件服务器磁盘配额管理.doc

    PAGE / NUMPAGES 封 面 作者:ZHANGJIAN 仅供个人学习,勿做商业用途 配额管理 Windows Server 203 R2"文件服务器"地"配额管 ...

  3. Ubuntu 和 Redhat / Fedora 服务管理命令对比表(附Fedora16新的服务管理工具systemctl )...

    以 apache/httpd 服务作为例子 任务 Red Hat / Fedora Ubuntu Ubuntu  (with sysv-rc-conf or sysvconfig) 立即启动/停止某服 ...

  4. 摩卡业务服务管理(Mocha BSM)解决方案

    方案概述 企业IT系统越来越多,网络.设备和产品越来越复杂,业越来越依赖于稳定可靠的系统运行,公司内部和外部用户对IT部门的支持服务和协调管理也提出了更高的要求.可是我们的IT部门被大量的设备所困扰, ...

  5. 企业数据移动服务管理软件SAP

    企业数据移动服务管理软件SAP SAP与全球主要的移动终端的开发商.制造商都保持着非常密切的合作关系.因此用户和合作伙伴基于SAP的移动平台只需要做一次开发,便可以自由决定是将这个应用置于Androi ...

  6. [MySQL Reference Manual] 5 MySQL 服务管理

    5. MySQL 服务管理 5. MySQL 服务管理 5.1 The Mysql Server 5.2 Mysql 服务日志 5.2.1 选择General query log和slow query ...

  7. 第四天 用户管理和服务管理

    复习: 判断题 1.在vim命令模式中输入:q!是强制不保存退出,只有root可以使用 2.在vim命令模式中ndd是复制多行 3.在vim命令模式中:%s/old/new/g会把文件中所有的old替 ...

  8. 服务管理---服务懂你的业务吗

         在我为跨国公司客户提供服务的多年时间里,我为客户.同事.团队成员提供了最好的技术和IT解决方案,这些获得公认的成功和价值.然而,这些年来我获得的最有价值的经验,是那些与我关系最密切的客户教导 ...

  9. linux查看服务依赖关系,服务管理(1)

    原标题:服务管理(1) 服务管理 什么是服务?在linux系统中,有一些特殊程序,启动后就会持续在后台执行,等待用户或者其他软件调用使用,这种程序我们称为服务. systemV与init system ...

最新文章

  1. Android调试工具_ Stetho
  2. 敏捷个人:提供更多文档下载,并转载一篇敏捷个人读书笔记
  3. yum search php7,yum install php7 in centos6
  4. 在MaxCompute上分析IP来源的方法
  5. P1601高精度加法
  6. STL标准模版库---set操作
  7. 服务器主板128G只显示出64G,[硬件维护]请教高手:新买的160G硬盘为什么分区后就只能显示128G?...
  8. 在c语言中1和0的意思,!1在c语言中是什么意思?
  9. StringUtils java
  10. C语言中,头文件和源文件的关系(转)
  11. 虚拟专题:联邦学习 | 联邦学习研究综述
  12. 6.继承下的构造函数域析构函数
  13. 《财富》推荐的75本必读书(转)
  14. 大面积卫片,无人机正射影像DOM修饰及无缝拼接快捷工具——PS
  15. css禁止图片保存,CSS的图片保存后面目全非?教你快速解决
  16. web三件套(经验贴)Google里,video标签播放mkv视频文件
  17. 阿里云超算战纪 | 凌云时刻
  18. new和malloc区别和malloc详解
  19. 8. ㊙ Python 集合三板斧,滚雪球学 Python
  20. 嵌入式邻域面试官必问的问题

热门文章

  1. word2vec原理_Word2vec详细整理(1)—权重更新原理
  2. 未正确安装master data services_GP数据库安装
  3. 计算机系统化科学化和什么,自动化概论复习资料
  4. php au著h权限管理,Jirafeau:一个简洁的临时文件分享系统,可随时删除
  5. 晟数学院 oracle,Oracle 控制文件存储解析
  6. 讲述华为发布鸿蒙系统,华为鸿蒙系统正式版首批升级名单公布:这8款机型用户有福了!...
  7. WebServlet 4.0
  8. Ajax与三层架构实训教案
  9. 《网易编程题》藏宝图
  10. Java笔试题库之编程题库 总共30道编程题,掌握了就可以应付中级以内Java面试题