croc

轻松安全地将东西从一台计算机发送到另一台计算机上。「Easily and securely send things from one computer to another

Github stars Tracking Chart

croc

croc 是一个允许任何两台电脑简单而安全地传输文件和文件夹的工具。据我(作者)所知,croc 是唯一一个 CLI 文件传输工具,它能做到以下所有功能。

允许任何两台电脑传输数据(使用中继)。
提供端到端加密(使用PAKE)。
可轻松实现跨平台传输(Windows、Linux、Mac)。
允许多文件传输
允许恢复被中断的传输
本地服务器或不需要端口转发
ipv6-first与ipv4后备

关于 croc 的更多信息,请看我的博客文章

安装

下载你系统的最新版本,或者从命令行安装一个版本。

$ curl https://getcroc.schollz.com | bash

在 macOS 上,你可以用 Homebrew 安装最新版本。

$ brew install croc

在 macOS 上,您也可以使用 MacPorts 安装最新版本。

$ sudo port selfupdate
$ sudo port install croc

在 Windows 上,你可以使用 ScoopChocolatey 安装最新版本。

$ scoop install croc
$ choco install croc

在 Unix 上,你可以使用 Nix 安装最新版本。

$ nix-env -i croc

在 Arch Linux 上,你可以使用 pacman 安装最新版本。

$ pacman -S croc

在 Ubuntu 上,你可以使用 snap 安装最新版本。

$ snap install croc

在 Termux 上,你可以使用 pkg 安装最新版本。

$ pkg install croc

或者,您可以安装 Go 并从源代码构建(需要 Go 1.12+)

$ GO111MODULE=on go get -v github.com/schollz/croc/v8

用法

要发送一个文件,只需这样做

$ croc send [file(s)-or-folder]
Sending 'file-or-folder' (X MB)
Code is: code-phrase

然后在另一台计算机上接收文件(或文件夹),你可以这样做

$ croc code-phrase

该代码短语用于建立密码认证密钥协议(PAKE),该协议为发送者和接收者生成一个秘密密钥,用于端到端加密。

有许多可配置的选项(见 --help)。一组选项(如自定义中继、端口和代码短语)可以使用 --remember 来设置。

自定义代码短语

您可以发送您自己的代码短语(必须超过4个字符)。

$ croc send --code [code-phrase] [file(s)-or-folder]

使用管道 -- stdin 和 stdout

你可以用管道传送到 croc。

$ cat [filename] | croc send

在这种情况下,croc 会自动使用 stdin 数据,发送并指定一个文件名,比如 "croc-stdin-123456789"。如果要接收到 stdout,你可以使用 --yes 自动批准传输,并把它管到 stdout。

$ croc --yes [code-phrase] > out

所有其他打印到控制台的文本都会被送到 stderr,所以它不会干扰发送到 stdout 的信息。

发送文本

有时你想发送 URL 或短文。除了管道,你还可以用 croc 轻松地发送文本。

$ croc send --text "hello world"

这将自动告诉接收者在接收文本时使用 stdout,这样文本就会被显示出来。

自主中继

中继器是需要固定并行的输入和输出连接的。默认情况下,croc 使用公共中继,但你也可以运行自己的中继。

$ croc relay

默认情况下,它使用 TCP 端口 9009-9013。确保打开这些端口。你可以自定义端口(例如 croc relay --ports 1111,1112),但你必须至少有2个端口用于中继。第一个端口是用来通讯的,后续的端口是用来进行多路数据传输的。

如果你想定制自己的主机,可以通过输入 --relay 来改变你正在使用的中继来发送文件。

$ croc --relay "myrelay.example.com:9009" send [filename]

注意,发送时只需包含第一个端口(通讯端口)。后续的数据传输端口将由中继传输回用户。

自主中继(docker)

如果更容易的话,你也可以用 Docker 运行一个中继。

$ docker run -d -p 9009-9013:9009-9013 -e CROC_PASS='YOURPASSWORD' schollz/croc

一定要包含中继的密码,否则任何请求都会被拒绝。

$ croc --pass YOURPASSWORD --relay "myreal.example.com:9009" send [filename]

注意:当包含 --pass YOURPASSWORD 时,你可以传递一个带有密码的文件,例如 --pass FILEWITHPASSWORD。

许可证

MIT

鸣谢

croc已经经历了许多次迭代,我对所有的伟大贡献感到惊讶!如果你想以任何方式贡献,你可以发送问题,PR,或在推特上问我(@yakczar)。如果你想以任何方式做出贡献,无论如何,你都可以发送一个 Issue、一个 PR、提出一个问题,或者给我发推特(@yakczar)。

感谢 @warner 的想法,@tscholl2 提供的加密要领,@skorokithakis 提供的代理两个连接的代码。最后感谢 @maximbaz, @meyermarcel, @Girbons, @techtide, @heymatthew, @Lunsford94, @lummie, @jesuiscamille, @threefjord 提出的拉取请求。@marcossegovia、@csleong98、@afotescu、@callmefever、@El-JojA、@anatolyyyyy、@goggle、@smileboywtu、@nicolashardy、@fbartels、@rkuprov、@xenrox和Ipar!

(The first version translated by vz on 2020.09.20)

Overview

Name With Ownerschollz/croc
Primary LanguageGo
Program languageGo (Language Count: 4)
PlatformLinux, Mac, Unix-like, Windows, BSD, Docker
License:MIT License
Release Count153
Last Release Namev9.6.15 (Posted on )
First Release Namev0.1.0 (Posted on )
Created At2017-10-17 15:20:18
Pushed At2024-04-06 16:44:27
Last Commit At
Stargazers Count26.3k
Watchers Count239
Fork Count1.1k
Commits Count1.8k
Has Issues Enabled
Issues Count431
Issue Open Count29
Pull Requests Count179
Pull Requests Open Count0
Pull Requests Close Count74
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

croc is a tool that allows any two computers to simply and securely transfer files and folders. AFAIK, croc is the only CLI file-transfer tool that does all of the following:

  • allows any two computers to transfer data (using a relay)
  • provides end-to-end encryption (using PAKE)
  • enables easy cross-platform transfers (Windows, Linux, Mac)
  • allows multiple file transfers
  • allows resuming transfers that are interrupted
  • local server or port-forwarding not needed
  • ipv6-first with ipv4 fallback
  • can use proxy, like tor

For more information about croc, see my blog post.

Example

Install

Download the latest release for your system, or install a release from the command-line:

curl https://getcroc.schollz.com | bash

On macOS you can install the latest release with Homebrew:

brew install croc

On macOS you can also install the latest release with MacPorts:

sudo port selfupdate
sudo port install croc

On Windows you can install the latest release with Scoop or Chocolatey:

scoop install croc
choco install croc

On Unix you can install the latest release with Nix:

nix-env -i croc

On Alpine Linux you have to install dependencies first:

apk add bash coreutils
wget -qO- https://getcroc.schollz.com | bash

On Arch Linux you can install the latest release with pacman:

pacman -S croc

On Gentoo you can install with portage:

emerge net-misc/croc

On Termux you can install with pkg:

pkg install croc

On FreeBSD you can install with pkg:

pkg install croc

Or, you can install Go and build from source (requires Go 1.15+):

go install github.com/schollz/croc/v9@latest

On Android there is a 3rd party F-Droid app available to download.

Usage

To send a file, simply do:

$ croc send [file(s)-or-folder]
Sending 'file-or-folder' (X MB)
Code is: code-phrase

Then to receive the file (or folder) on another computer, you can just do

croc code-phrase

The code phrase is used to establish password-authenticated key agreement (PAKE) which generates a secret key for the sender and recipient to use for end-to-end encryption.

There are a number of configurable options (see --help). A set of options (like custom relay, ports, and code phrase) can be set using --remember.

Custom code phrase

You can send with your own code phrase (must be more than 6 characters).

croc send --code [code-phrase] [file(s)-or-folder]

Allow overwriting without prompt

By default, croc will prompt whether to overwrite a file. You can automatically overwrite files by using the --overwrite flag (recipient only). For example, receive a file to automatically overwrite:

croc --yes --overwrite <code>

Use pipes - stdin and stdout

You can pipe to croc:

cat [filename] | croc send

In this case croc will automatically use the stdin data and send and assign a filename like "croc-stdin-123456789". To receive to stdout at you can always just use the --yes will automatically approve the transfer and pipe it out to stdout.

croc --yes [code-phrase] > out

All of the other text printed to the console is going to stderr so it will not interfere with the message going to stdout.

Send text

Sometimes you want to send URLs or short text. In addition to piping, you can easily send text with croc:

croc send --text "hello world"

This will automatically tell the receiver to use stdout when they receive the text so it will be displayed.

Use a proxy

You can use a proxy as your connection to the relay by adding a proxy address with --socks5. For example, you can send via a tor relay:

croc --socks5 "127.0.0.1:9050" send SOMEFILE

Change encryption curve

You can choose from several different elliptic curves to use for encryption by using the --curve flag. Only the recipient can choose the curve. For example, receive a file using the P-521 curve:

croc --curve p521 <codephrase>

Available curves are P-256, P-348, P-521 and SIEC. SIEC is the default curve used, it is a lesser known curve that belongs to a class of "super-isolated" curves which has security that does not reduce to the security of curves around it. (Scholl, Travis. Experimental Mathematics 28.4 (2019): 385-397)

Self-host relay

The relay is needed to staple the parallel incoming and outgoing connections. By default, croc uses a public relay but you can also run your own relay:

croc relay

By default it uses TCP ports 9009-9013. Make sure to open those up. You can customized the ports (e.g. croc relay --ports 1111,1112), but you must have a minimum of 2 ports for the relay. The first port is for communication and the subsequent ports are used for the multiplexed data transfer.

You can send files using your relay by entering --relay to change the relay that you are using if you want to custom host your own.

croc --relay "myrelay.example.com:9009" send [filename]

Note, when sending, you only need to include the first port (the communication port). The subsequent ports for data transfer will be transmitted back to the user from the relay.

Self-host relay (docker)

If it's easier you can also run a relay with Docker:

docker run -d -p 9009-9013:9009-9013 -e CROC_PASS='YOURPASSWORD' schollz/croc

Be sure to include the password for the relay otherwise any requests will be rejected.

croc --pass YOURPASSWORD --relay "myreal.example.com:9009" send [filename]

Note: when including --pass YOURPASSWORD you can instead pass a file with the password, e.g. --pass FILEWITHPASSWORD.

License

MIT

Acknowledgements

croc has gone through many iterations, and I am awed by all the great contributions! If you feel like contributing, in any way, by all means you can send an Issue, a PR, ask a question, or tweet me (@yakczar).

Thanks @warner for the idea, @tscholl2 for the encryption gists, @skorokithakis for code on proxying two connections. Finally thanks for making pull requests @maximbaz, @meyermarcel, @Girbons, @techtide, @heymatthew, @Lunsford94, @lummie, @jesuiscamille, @threefjord, @marcossegovia, @csleong98, @afotescu, @callmefever, @El-JojA, @anatolyyyyyy, @goggle, @smileboywtu, @nicolashardy, @fbartels, @rkuprov, @hreese, @xenrox and Ipar!

To the top