bash 单线FTP服务器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6811258/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 00:25:58  来源:igfitidea点击:

One Line FTP Server

linuxbashftp

提问by André Puel

A lot of times I used the command, which opens a temporary HTTP server on current directory:

很多时候我使用了这个命令,它在当前目录上打开一个临时的 HTTP 服务器:

python3 -m http.server

Now I need to receive files, is there any one-line command that opens a ftp server?

现在我需要接收文件,有没有打开ftp服务器的单行命令?

I am simply looking for a command line ftp server, no configurations files, no daemons.

我只是在寻找命令行 ftp 服务器,没有配置文件,没有守护进程。

I tried Twisted as in One line ftp server in python, but the user has no permission to send files...

在 python中的One line ftp server 中尝试了 Twisted ,但是用户没有发送文件的权限......

回答by icyrock.com

If you are looking for a Python solution, check out pyftpdlib.

如果您正在寻找 Python 解决方案,请查看pyftpdlib

You can install it using e.g. pip:

您可以使用例如 pip 安装它:

pip install pyftpdlib

then run it like this:

然后像这样运行它:

python -m pyftpdlib

This runs the anonymous-writable FTP server at localhost, port 2121 by default, serving files from the current directory (i.e. from wherever you started it). To login, use anonymousas both username and password.

这将在本地主机上运行匿名可写 FTP 服务器,默认端口为 2121,从当前目录(即从您启动它的任何地方)提供文件。要登录,请使用匿名作为用户名和密码。

Obviously, this is very insecure, so you would have to take that into account - if you want anything more then a toy or something to work with in development etc., use a proper FTP server as others mentioned.

显然,这是非常不安全的,因此您必须考虑到这一点 - 如果您想要的不仅仅是玩具或开发中的其他东西,请使用其他人提到的适当的 FTP 服务器。

回答by kjakeb

One common command line ftp server is vsftpd. This is also the default ftp server on Ubuntu, CentOS, Fedora, NimbleX and RHEL Linux.

一种常见的命令行 ftp 服务器是vsftpd。这也是 Ubuntu、CentOS、Fedora、NimbleX 和 RHEL Linux 上的默认 ftp 服务器。

回答by Rufo El Magufo

Openssh has a SFTP server and the configuration is very easy.

Openssh 有一个 SFTP 服务器,配置非常简单。

FYI, plain FTP is more complex than HTTP. Take with care :)

仅供参考,普通 FTP 比 HTTP 更复杂。小心点:)

回答by iX3

Here's a solution using NodeJS(ftp-srvmodule)

这是使用NodeJSftp-srv模块)的解决方案

npx ftp-srv ftp://0.0.0.0:2121 --root .

npx ftp-srv ftp://0.0.0.0:2121 --root .

This starts an FTP server listening on TCP port 2121 on all interfaces, which uses the current directory as the root (this is actually the default, so the --root .could be omitted for this particular case) and accepts all logins. (npxdownloads the module and runs its main script with the options provided.)

这将启动一个 FTP 服务器,侦听所有接口上的 TCP 端口 2121,它使用当前目录作为根目录(这实际上是默认值,因此--root .对于这种特殊情况可以省略)并接受所有登录。(npx下载模块并使用提供的选项运行其主脚本。)

You may also want to check out the --pasv_urloption to enable passive mode.

您可能还想查看--pasv_url启用被动模式的选项。

For more details, see https://www.npmjs.com/package/ftp-srv#cli

更多详情,请参见https://www.npmjs.com/package/ftp-srv#cli

Options:
  --help             Show help                                         [boolean]
  --version          Show version number                               [boolean]
  --credentials, -c  Load user & pass from json file                    [string]
  --username         Blank for anonymous                  [string] [default: ""]
  --password         Password for given username                        [string]
  --root, -r         Default root directory for users                   [string]
  --read-only        Disable write actions such as upload, delete, etc
                                                      [boolean] [default: false]
  --pasv_url         URL to provide for passive connections             [string]
  --pasv_min         Starting point to use when creating passive connections
                                                        [number] [default: 1024]
  --pasv_max         Ending port to use when creating passive connections
                                                       [number] [default: 65535]