文件传输协议:修订间差异

删除的内容 添加的内容
BluEmaP1E留言 | 贡献
Iamnotlin4留言 | 贡献
无编辑摘要
标签2017版源代码编辑
 
(未显示21个用户的44个中间版本)
第1行:
{{NoteTA
| G1 = IT
|1=zh-cn:客户端;zh-tw:用戶端;
}}
{{Redirect|FTP}}
{{多個問題|
{{original research|time=2019-01-22T10:24:04+00:00}}
{{Expand English|File Transfer Protocol}}
{{refimprove|time=2016-09-23T03:23:44+00:00}}
}}
{{网络协议}}
'''文件传输协议'''({{Lang-en|'''F'''ile '''T'''ransfer '''P'''rotocol}},縮寫'''FTP''')是一个用於[[網絡|<span data-segmentid="4" class="cx-segment"></span>]][[计算机网络]]上在<span data-segmentid="4" class="cx-segment">[[主從式架構|客户端和服务器]]</span>之進行傳輸文件傳輸的[[应用层]]<span data-segmentid="4" class="cx-segment">[[网络传输协议|协议]]</span>传送文件传送(file transfer)和存取文件存取(file access)之间的区别在于:前者由FTP提供,后者由[[网络文件系统|NFS]]等应用系统提供<ref>{{Cite book|title=TCP/IP详解 卷一:协议|year=2000|url=https://archive.org/details/tcpipxiangjiejua0000unse|last=W.Richard Stevevs 著|first=范建华 等译|publisher=机械工业|year=|isbn=978-7-111-07566-0|location=|pages=316}}</ref>。参考文献[https://www.ietfarchive.org/rfcdetails/rfc959.txttcpipxiangjiejua0000unse/page/316 RFC959316]定义了此}}</ref>。由<nowiki/>RFC 959<nowiki/>规范。
 
FTP是一个8位的客户端-服务器协议,能操作任何类型的文件而不需要进一步後續处理,就像MIME或[[Unicode]]一样是,FTPFTP极高的延时,意味着,从开始请求到第一次接收需求数据间的时间,会非常长;并且必须不时的必须执行一些冗长的登录进程。
 
== FTP 服务器历史 ==
文件传输协议的Abhay Bhushan编写原始规范,并于1971年4月16日发布<nowiki/>RFC 114<nowiki/>发布。直到1980年,FTP运行[[TCP/ IP]]的前身NCP运行。该协议后来被TCP / IP版本,[[Request,RFC for Comments|RFC]]&nbsp;[[rfc:765|765]](1980765(1980年6月)和[[rfc:959|取代,后来又被 RFC&nbsp;959]](1985 959(1985年10月)()所取代,这也是当前规范)所取代<nowiki>RFC&nbsp; 959<nowiki/nowiki>提出了若干标准修改,例如 RFC 1579(1994年2月)使 FTP 能够穿越[[rfc:1579网络地址转换|RFC&nbsp;1579NAT]](1994年2月)启用与[[防火墙FTP(]](被动模式),[[rfc:2228|RFC&nbsp;2228]](1997),RFC 2228(1997年6月)提出安全扩展,[[rfc:2428|RFC&nbsp;2428]](1998,RFC 2428(1998年9月)增加了对[[IPv6|IPv6的]]支持,并定义了一种新型的被动模式。&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
== 概述 ==
第22行:
 
运行FTP服务的许多站点都开放匿名服务,在这种设置下,用户不需要帐号就可以登录服务器,默认情况下,匿名用户的用户名是:「anonymous」。这个帐号不需要密码,虽然通常要求输入用户的邮件地址作为认证密码,但这-{只}-是一些细节或者此邮件地址根本不被确定,而是依赖于FTP服务器的配置情况。
 
可以被傳送到[[FTP]][[服务器|伺服器]]的'''[[FTP命令列表]]''',包含由[[IETF]]在<nowiki>RFC 959</nowiki>中標準化的所有命令。需要注意的是,大多數命令列FTP用戶端都給用戶提供了額外的命令集。例如,GET是一個常見的用來下載檔案的用戶命令,用來替代原始的RETR命令。
 
===FTP实现的目标===
第40行 ⟶ 第38行:
# 服务器打开20号源端口并且建立和客户端数据端口的连接。此时,來源地的端口为20,远程数据(目的地)端口为(x+1)。
# 客户端通过本地的数据端口建立一个和服务器20号端口的连接,然后向服务器发送一个应答,告诉服务器它已经建立好了一个连接。
 
== 软件支持 ==
=== FTP和网页浏览器 ===
大部分常见的[[网页浏览器]]都可以检索FTP服务器上托管的文件,尽管它们并不支持扩展协议,如[[FTPS]]。<ref name="matthews">{{cite book |last=Matthews |first=J. |year=2005 |title=Computer Networking: Internet Protocols in Action |url=https://archive.org/details/computernetworki0000matt |edition=1st |location=Danvers, MA |publisher=John Wiley & Sons Inc.}}</ref>当浏览器访问FTP格式的URL时,将以Web文件目录显示远程服务器上的可访问内容。使用类似{{link-en|FireFTP|FireFTP}}客户端可获得FTP扩展协议的完整支持。
 
Chrome和Firefox等主流浏览器都将计划弃用对FTP的支持,<ref>{{cite web|url=https://www.bleepingcomputer.com/news/google/chrome-and-firefox-developers-aim-to-remove-support-for-ftp/|title=Chrome and Firefox Developers Aim to Remove Support for FTP|date=2018-11-26|access-date=2020-01-26|website=bleepingcomputer.com|first1=Lawrence|last1=Abrams|archive-date=2020-11-08|archive-url=https://web.archive.org/web/20201108115459/https://www.bleepingcomputer.com/news/google/chrome-and-firefox-developers-aim-to-remove-support-for-ftp/|dead-url=no}}</ref>2019年推出的Chrome 82已停止对FTP支持<ref>{{cite web |author=Martin Brinkmann |title=Google Chrome 82 won't support FTP anymore |url=https://www.ghacks.net/2019/08/16/google-chrome-82-wont-support-ftp-anymore/ |website=ghacks |accessdate=2020-04-20 |language=en |date=2019-08-16 |archive-date=2021-02-05 |archive-url=https://web.archive.org/web/20210205132606/https://www.ghacks.net/2019/08/16/google-chrome-82-wont-support-ftp-anymore/ |dead-url=no }}</ref>,在2020年因[[COVID-19疫情]]增加的[[遠距辦公]]需求而短暫恢復FTP,但於2021年10月推出的Chrome95完全移除FTP相關程式碼<ref>{{cite news |author1=林妍溱 |title=Google Chrome 95將徹底移除FTP程式碼 |url=https://www.ithome.com.tw/news/147392 |accessdate=2021-10-21 |publisher=iThome |date=2021-10-21 |archive-date=2021-10-27 |archive-url=https://web.archive.org/web/20211027120324/https://www.ithome.com.tw/news/147392 |dead-url=no }}</ref>。而Firefox原預定于版本77中停止支持FTP<ref>{{cite web |author=Martin Brinkmann |title=Mozilla will remove FTP support in the Firefox web browser |url=https://www.ghacks.net/2020/03/19/mozilla-will-remove-ftp-support-in-the-firefox-web-browser/ |website=ghacks |accessdate=2020-04-20 |language=en |date=2020-03-19 |archive-date=2021-02-22 |archive-url=https://web.archive.org/web/20210222142344/https://www.ghacks.net/2020/03/19/mozilla-will-remove-ftp-support-in-the-firefox-web-browser/ |dead-url=no }}</ref>,最終在2021年7月發行的90版正式停止支援FTP協定<ref>{{cite news |author1=林妍溱 |title=Firefox 90正式終止支援FTP |url=https://www.ithome.com.tw/news/145834 |accessdate=2021-10-21 |publisher=iThome |date=2021-07-23 |archive-date=2021-10-25 |archive-url=https://web.archive.org/web/20211025195633/https://www.ithome.com.tw/news/145834 |dead-url=no }}</ref>。微軟的[[Edge瀏覽器]]也在2020年起停止支援FTP,[[Internet Explorer 11]]仍保留FTP用戶端,直到2022年6月15日終止支援<ref>{{cite web |author1=郑丽媛 |title=FTP 时代已逝:Firefox、Chrome 等多个浏览器均已弃用! |url=https://mp.weixin.qq.com/s?__biz=MjM5MjAwODM4MA==&mid=2650857604&idx=1&sn=1ae9ed435e0d85416119de1f5ccf168c&chksm=bd5891578a2f1841067fd3b6c482376e27bd6b444937b0deb0a2c32653d5bca2aac0db0a7bd2&scene=27#wechat_redirect |website=CSDN微信公眾號 |accessdate=2021-07-23 |archive-date=2021-10-25 |archive-url=https://web.archive.org/web/20211025192441/https://mp.weixin.qq.com/s?__biz=MjM5MjAwODM4MA==&mid=2650857604&idx=1&sn=1ae9ed435e0d85416119de1f5ccf168c&chksm=bd5891578a2f1841067fd3b6c482376e27bd6b444937b0deb0a2c32653d5bca2aac0db0a7bd2&scene=27#wechat_redirect |dead-url=no }}</ref>。
 
====语法====
FTP URL 格式已在{{IETF RFC|1738}}指定,格式为:<code>ftp://[user[:password]@]host[:port]/url-path</code>(方括号内为可选参数)。
 
有关指定用户名和密码的更多详细信息,可以在浏览器的文档中找到(例如[[Firefox]]<ref>{{cite web |url=https://support.mozilla.org/en-US/kb/Accessing%20FTP%20servers#w_ftp-servers-that-require-a-username-and-password |title=Accessing FTP servers &#124; How to &#124; Firefox Help |publisher=Support.mozilla.com |date=2012-09-05 |accessdate=2013-01-16 |archive-date=2021-01-26 |archive-url=https://web.archive.org/web/20210126004632/https://support.mozilla.org/en-US/kb/Accessing%20FTP%20servers#w_ftp-servers-that-require-a-username-and-password |dead-url=no }}</ref>和[[Internet Explorer]]<ref>{{Cite web |url=https://support.microsoft.com/en-us/kb/135975 |title=How to Enter FTP Site Password in Internet Explorer |access-date=2020-04-20 |archive-url=https://web.archive.org/web/20150702005840/https://support.microsoft.com/en-us/kb/135975 |archive-date=2015-07-02 |dead-url= }} Written for IE versions 6 and earlier. Might work with newer versions.</ref>)。默认情况下,大多数Web浏览器使用被动(PASV)模式,该模式更容易遍历终端防火墙。
 
=== 下载管理器 ===
大部分常见的[[下载管理器]]都可以收取FTP服务器上托管的文件,其中一些还提供界面来检索FTP服务器上托管的文件。{{link-en|DownloadStudio|DownloadStudio}}和Internet Download Accelerator既能从FTP服务器下载文件,又能查看FTP服务器上的文件。<ref>{{cite web |url=http://www.conceiva.com/products/downloadstudio/features.asp |title=DownloadStudio - Internet Download Manager And Download Accelerator - Features |author= |publisher=Conceiva |date= |access-date=2021-10-19 |archive-date=2021-09-08 |archive-url=https://web.archive.org/web/20210908015938/http://www.conceiva.com/products/downloadstudio/features.asp |dead-url=no }}</ref><ref>{{cite web |url=https://www.westbyte.com/ida/index.phtml?page=features&tmp=1&lng=English |title=Internet Download Accelerator {{!}} Features |author= |publisher=WestByte |date= |access-date=2021-10-20 |archive-date=2021-09-04 |archive-url=https://web.archive.org/web/20210904171532/https://westbyte.com/ida/index.phtml?page=features&tmp=1&lng=English |dead-url=no }}</ref>
 
===其他===
[[LibreOffice]]支持打开FTP服务器上的文件,但从7.4版本起,这一功能被标记为过时,开发者打算在将来的版本中将其移除。<ref>{{Cite web |url=https://wiki.documentfoundation.org/ReleaseNotes/7.4 |title=LibreOffice 7.4: Release Notes |publisher=The Document Foundation's Wiki |accessdate=2022-09-10 |archive-date=2022-08-24 |archive-url=https://web.archive.org/web/20220824072927/https://wiki.documentfoundation.org/ReleaseNotes/7.4 |dead-url=no }}</ref>
 
== 安全性 ==
<span data-segmentid="152" class="cx-segment">FTP不是一项安全的协议,并且具有许多安全漏洞<ref name="nurdle">{{Cite web|title=Securing FTP using SSH|url=http://www.nurdletech.com/linux-notes/ftp/ssh.html|publisher=Nurdletech.com|access-date=2019-01-22|archive-date=2020-11-24|archive-url=https://web.archive.org/web/20201124230128/https://nurdletech.com/linux-notes/ftp/ssh.html|dead-url=no}}</ref>。</span><span data-segmentid="153" class="cx-segment">1999年5月</span><span data-segmentid="152" class="cx-segment">发布的</span><span data-segmentid="153" class="cx-segment">{{IETF RFC|2577}}</span>中<span data-segmentid="153" class="cx-segment">列出了以下几个主要的漏洞:</span>
 
* [[攻击破解]]
* <span data-segmentid="157" class="cx-segment">[[FTP bounce attack{{link-en|FTP反弹攻击]]|FTP bounce attack}}</span>
* [[數據包分析器|数据包捕获]]
* <span data-segmentid="161" class="cx-segment">端口窃取(猜测下一个开放端口并篡夺合法连接)</span>
* <span data-segmentid="162" class="cx-segment">[[Spoofing attack|欺骗攻击]]</span>
* <span data-segmentid="164" class="cx-segment">[[用户|用户名]]枚举</span>
 
<span data-segmentid="166" class="cx-segment">通过FTP传输的流量不会被加密,所有传输通过明文进行的。任何能够在网络上执行数据包捕获( [[數據包分析器|嗅探]] )的人都可以读取用户名、密码、命令内容和数据<ref name="tcpip">{{Cite web|author=Kozierok|first=Charles M.|year=2005|title=The TCP/IP Guide v3.0|url=http://www.tcpipguide.com/free/t_FTPOverviewHistoryandStandards.htm|publisher=Tcpipguide.com|access-date=2019-01-22|archive-date=2021-01-11|archive-url=https://web.archive.org/web/20210111073429/http://www.tcpipguide.com/free/t_FTPOverviewHistoryandStandards.htm|dead-url=no}}</ref><ref name="nurdle2">{{Cite web|title=Securing FTP using SSH|url=http://www.nurdletech.com/linux-notes/ftp/ssh.html|publisher=Nurdletech.com|access-date=2019-01-22|archive-date=2020-11-24|archive-url=https://web.archive.org/web/20201124230128/https://nurdletech.com/linux-notes/ftp/ssh.html|dead-url=no}}</ref>。</span><span data-segmentid="168" class="cx-segment">此问题在加密机制(如[[傳輸層安全性協定|TLS]]或SSL)产生之前的许多Internet协议规范(如[[简单邮件传输协议|SMTP]] 、[[Telnet]] 、POP和IMAP)中较为普遍<ref name="clark">{{Cite book|title=Data Networks IP and the Internet|last=Clark|first=M.P.|publisher=John Wiley & Sons Ltd.|year=2003|edition=1st|location=West Sussex, England}}</ref>。</span>
 
<span data-segmentid="172" class="cx-segment">此问题的常见解决方案包括:</span>
第59行 ⟶ 第74行:
# <span data-segmentid="179" class="cx-segment">使用安全隧道(如[[Secure Shell]]或[[虛擬私人網路]] )。</span>
 
===缺点{{Or}}= FTP 命令 ==
{{Main|FTP命令列表}}
可以被傳送到[[FTP]][[服务器|伺服器]]的'''[[FTP命令列表]]''',包含由[[IETF]]在<nowiki>RFC 959</nowiki>中標準化的所有命令。需要注意的是,大多數命令列FTP用戶端都給用戶提供了額外的命令集。例如,GET是一個常見的用來下載檔案的用戶命令,用來替代原始的RETR命令。
 
== FTP 服务器返回码 ==
# 因为必须开放一个随机的端口以建立连接,当防火墙存在时,客户端很难过滤处于主动模式下的FTP流量。这个问题,通过使用被动模式的FTP,得到了很大解决。
{{Main|FTP服务器返回码}}
# 服务器可能会被告知连接一个第三方计算机的保留端口。
包含由[[IETF]]在<nowiki>RFC 959</nowiki>中標準化的所有服务器返回码。回复代码是一个三位数值,第一个数字用于表示三种可能的结果之一————成功、失败、表示错误或不完整的回复。
# 此方式在需要傳輸檔案數量很多的小檔案時,效能不好。
 
== <span data-segmentid="194" class="cx-segment">衍生品</span> ==
 
=== FTPS ===
=== <span data-segmentid="195" class="cx-segment">FTPS</span> ===
{{Main|FTPS}}
'''FTPS'''是FTP标准的扩展,添加了[[安全套接层]](SSL)以及其继任者[[傳輸層安全性協定]](TLS)的支持。
<span data-segmentid="196" class="cx-segment">显式FTPS是FTP标准的扩展,允许客户端请求加密FTP会话。</span><span data-segmentid="197" class="cx-segment">这是通过发送“AUTH TLS”命令完成的。</span><span data-segmentid="198" class="cx-segment">服务器可以选择允许或拒绝不请求TLS的连接。</span><span data-segmentid="199" class="cx-segment">该协议扩展定义于{{IETF RFC|4217}}</span> 。<span data-segmentid="201" class="cx-segment">隐式FTPS是FTP的过时标准,需要使用SSL或TLS连接。</span><span data-segmentid="202" class="cx-segment">它被指定</span><span data-segmentid="201" class="cx-segment">于和</span><span data-segmentid="202" class="cx-segment">普通FTP不同的端口。</span>
 
=== <span data-segmentid="203" class="cx-segment">SSH文件传输协议</span> ===
{{Main|SFTP}}
<span data-segmentid="204" class="cx-segment">'''SSH文件传输协议'''(缩写:SFTP)可用于传输文件并具有类似的用户命令集,但使用[[Secure Shell]]协议(SSH)传输文件。</span> <span data-segmentid="206" class="cx-segment">与FTP不同,它对命令和数据进行加密,防止密码和敏感信息通过网络公开传输。</span><span data-segmentid="207" class="cx-segment">它无法与FTP兼容。</span>
 
=== 小型文件传输协议 ===
{{Main|TFTP}}
'''小型文件传输协议'''(Trivial File Transfer Protocol, TFTP),是一种于1981年在RFC 783中定义的简化的文件传输协议(FTP)。
 
=== <span data-segmentid="208" class="cx-segment">简单文件传输协议</span> ===
<span data-segmentid="216" class="cx-segment">'''简单文件传输协议(英语:Simple'''(Simple File Transfer Protocol)由{{IETF RFC|913}}定义,其复杂程度介于TFTP和FTP之间。</span> <span data-segmentid="218" class="cx-segment">它从未在[[互联网]]上被广泛接受。</span><span data-segmentid="221" class="cx-segment">它通过端口115运行</span><span data-segmentid="222" class="cx-segment">,支持三种类型的数据传输: [[ASCII]] 、 [[二进制文件|二进制]]和连续。</span><span data-segmentid="227" class="cx-segment">该协议还支持使用用户</span><span data-segmentid="222" class="cx-segment"></span><span data-segmentid="227" class="cx-segment">和密码登录</span><span data-segmentid="222" class="cx-segment"></span><span data-segmentid="227" class="cx-segment">文件夹和文件管理(包括''重命名''、''删除''、''上传''、''下载'')。</span>
 
== FTP和网页浏览器 ==
大多数最新的[[网页浏览器]]和文件管理器都能和FTP服务器建立连接。这使得在FTP上通过一个接口就可以操控远程文件,如同操控本地文件一样。这个功能通过给定一个FTP的URL实现,形如<nowiki>ftp://</nowiki><服务器地址>(例如,ftp://ftp.gimp.org )。是否提供密码是可选择的,如果有密码,则形如<nowiki>ftp://<login>:<password>@<ftpserveraddress></nowiki>。大部分网页浏览器要求使用被动FTP模式,然而并不是所有的FTP服务器都支持被动模式。
 
== 参考文献 ==
=== 引用 ===
{{Reflist}}
 
=== 来源 ===
* RFC 0959文件传输协议。J.Postel, J.Reynolds. 1985.10(格式:文本,147316字节。http://www.ietf.org/rfc/rfc959.txt )。最早的RFC 114和之后的RFC 765已被废除。
{{ReflistH}}
* RFC 0959文件传输协议》. J. Postel,; J. Reynolds. 1985.10(格式:文本,147316字节. http://www.ietf.org/rfc/rfc959.txt {{Wayback|url=http://www.ietf.org/rfc/rfc959.txt |date=20130326015352 }}. 最早的RFC 114和之后的RFC 765已被废除。
{{ReflistF}}
 
== 参见 ==
第102行 ⟶ 第121行:
 
== 外部链接 ==
* [http://www.cnpaf.net/class/ftp FTP协议详细资料]
 
 
{{normdaten}}
[[Category:文件传输协议]]
[[Category:网络协议FTP| ]]
[[Category:应用层协议]]
[[Category:网络软件網際網路歷史]]
[[Category:服务器互联网标准]]
[[Category:網際網路的歷史网络文件传输协议]]
[[Category:1980年面世Unix网络相关软件]]
[[Category:文件传输协议檔案分享]]