哪个更安全——使用套接字编程或 SSH/SCP/FTP 进行数据传输
我仍在学习套接字编程(使用 Perl),但我有两个选项(套接字编程和 SSH/SCP/FTP)可用于将数据从远程计算机传输到本地服务器。
但我必须选择一种在数据传输方面更安全(网络上的加密数据)的方法。任何建议。
I am still learning socket programming (using Perl) but I have both options ( socket programming and SSH/SCP/FTP) available to transfer the data from remote machines to my local servers.
But I have to select one which is more secure ( encrypted data on network) in terms of data transfer. Any suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
仅使用套接字根本无法给您带来任何安全性。正确的选择取决于应用程序、您使用的系统以及用户对使用它需要做什么的了解程度。例如,如果您以安全的方式与 Web 服务器交互,您可能最终会使用 TLS/SSL。如果您只是在两个系统之间传输数据,那么使用 ssh 可能是最方便的方法。
当你说“安全”时,你是在寻找网络上的加密数据吗?通信双方的身份验证?两个都?
另一种选择是使用 TLS/SSL,可能与 OpenSSL 工具包一起使用(并且有带有绑定的 Perl 模块。)编程比使用 ssh 更复杂,并且您必须在身份验证方面做更多工作,因此它回到你想做的事情。
此外,FTP 本身也不安全。
Just using sockets doesn't give you any security at all. The right choice depends on the application, the systems you're using, and how much the users understand about what they need to do to use it. For example, if you're interacting with a web server in a secure way, you'll probably end up using TLS/SSL for it. If you're just transferring data between two systems, using ssh might well be the most convenient way.
When you say "security", are you looking for encrypted data on the network? Authentication of the communicating parties? Both?
Another alternative is using TLS/SSL, probably with the OpenSSL toolkit (and there are Perl modules with bindings for it.) The programming is more complicated than with ssh, and you'll have to do more work on authentication for it, so it comes back to whatever it is you're trying to do.
Also, FTP isn't secure on its own either.
所有网络编程都在底层使用套接字。
所以这只是你使用的协议的问题。
一般来说,如果您想保证安全,您应该使用 SSL(https、sftp、ftps)建立隧道通信
All network programming uses Sockets under the hood.
So it's rather a matter of protocols you use.
Generally, if you want to be secure you should tunnel your communication using SSL (https, sftp, ftps)
SSH/SFTP/SCP都利用socket进行socket编程。除非您有比 SSH 提供的更好的算法(出于安全考虑),否则请使用 Perl 的 SSH 模块。
SSH/SFTP/SCP all makes use of sockets under socket programming. Unless you have a better algorithm (for security) than what SSH provides, use a SSH module for Perl.
SSH 是一种远程 shell 协议,它本身不用于文件传输(如 FTP)。 SCP 文件传输协议是 SSH1 的一部分,但由于 SSH1 已经过时且存在缺陷,因此不建议使用 SCP。在 SSH2(用于所有现代系统)中,使用 SFTP(SSH 文件传输协议)。
FTP (RFC 959) 本身不提供任何安全性。现有的扩展允许您通过 SSL/TLS 运行 FTP(通过预加密通道隐式运行,或者通过 TLS 作为 FTP 协议的一部分显式运行)。基于 SSL 的 FTP 称为 FTPS(不要将其与 SFTP 混合)。
您可以在此处阅读 FTPS 和 SFTP 优缺点的详细说明。
SSH is a remote shell protocol and itself it is not used for file transfer (like FTP). SCP file transfer protocol was part of SSH1 but as SSH1 is outdated and flawed, SCP is not recommended for use. In SSH2 (used in all modern systems) SFTP (SSH File Transfer Protocol) is used.
FTP (RFC 959) by itself doesn't provide any security. There exist extensions that let you run FTP over SSL/TLS (either implicitly, over pre-encrypted channel, or explicitly, via TLS as a part of FTP protocol). FTP over SSL is called FTPS (don't mix it with SFTP).
You can read detailed descriptions of pros and cons of FTPS and SFTP here.
开箱即用的插座并不安全。数据以原始形式从 A 点传输到 B 点。
添加 SSL 可以增加安全性。许多协议都支持 SSL。特别是多种 FTP 和 HTTP 支持 SSL。
FTPS 受到许多平台和许多客户端的广泛支持。即使您编写自定义客户端,手头有其他客户端(例如 FileZilla)进行测试也是很好的。
如果我要从头开始构建这样的系统,我会使用 FTPS。
Out of the box sockets aren't secure. The data is transmitted in raw form from point A to point B.
Adding SSL adds security. Many protocols support SSL. In particular several flavors of FTP and HTTP support SSL.
FTPS is a widely supported on many platforms and by many clients. Even if you write a custom client, having other clients like FileZilla at hand for testing is nice.
If I were to start from scratch on such a system I would use FTPS.
我会考虑三个主要选项:
FTPS(基于 SSL/TLS 的 FTP) - 它相当于 HTTPS,简单来说意味着它是普通 FTP 协议的加密版本。我认为它非常适合通过互联网从远程机器(可能是公共机器)下载。它以 X.509 证书的形式提供卓越的身份验证机制。防火墙存在一些问题,因为它像 FTP 一样使用两个连接。如果您的目标是防止任何人看到您正在下载的内容,恕我直言,这是完美的解决方案。我倾向于使用此协议来访问我无法控制的计算机。
SFTP (SSH FTP) - 这是一个很好的协议,可能比 FTPS 优越一些,但在我看来它更适合受控环境。当我想将文件从一台计算机上的帐户下载到另一台计算机时,我将使用此协议。或者当我想将新脚本上传到服务器时。对我来说,远程相当于我使用闪存驱动器访问机器并登录机器。
VPN - 如果这些机器是固定的,可以这么说 - 你总是连接到相同的机器 - 我会考虑使用 VPN 来提供安全性。传输受到保护,不受外界干扰,服务器的行为就像在同一网络中一样,我可以使用我想要的任何协议。
I would consider three main options:
FTPS (FTP over SSL/TLS) - it's equivalent of HTTPS which in simple terms means it's encrypted version of the ordinary FTP protocol. I think it's great for downloading over the Internet from remote and possibly public machines. It offers superior authentication mechanism in the form of X.509 certificates. There is some trouble with firewalls because it uses, as FTP does, two connections. If your goal is to prevent anyone from seeing what you're downloading this is IMHO perfect solution. I tend to use this protocol to access machines that I don't control.
SFTP (SSH FTP) - it's good protocol, maybe bit superior to the FTPS, but in my opinion it's better suited for controlled environment. I will use this protocol when I want to download a file from my account on one machine to another. Or when I want to upload new script to a server. It's for me remote equivalent of me going to the machine with flash drive and logging on the machine.
VPN - if those machines are fixed so to speak - you are always connecting to the same machines - I would consider using VPN to deliver the security. The transmissions are protected from outsiders, the server behaves like it's in the same network and I can use any protocol I want.