Croc:在两台计算机之间安全地传输文件和文件夹
Croc: Securely transfer files and folders between two computers

原始链接: https://github.com/schollz/croc/

**croc** 是一款功能强大的跨平台命令行工具,旨在实现任意两台计算机之间简单且安全的文件和文件夹传输。它的一大特色是利用密码验证密钥交换(PAKE)提供端到端加密,且无需端口映射或本地服务器。 **主要特性包括:** * **安全与多功能性:** 支持端到端加密、代理/Tor 集成以及 IPv6/IPv4 兼容。 * **用户体验:** 允许断点续传、发送多个文件、管道输出,并能生成用于移动端访问的二维码。 * **易用性:** 通过简单的口令即可发起传输,口令会自动复制到剪贴板。 * **灵活性:** 可通过多种软件包管理器(如 Homebrew、Winget、Nix、Docker 等)轻松安装在 Windows、Linux 和 macOS 上。 * **自定义:** 高级用户可自建中继服务器以构建私有基础设施,或使用自定义加密曲线。 无论您是需要发送文本、链接还是大型文件夹,croc 都为现代文件共享提供了一种精简、安全且可脚本化的解决方案。欢迎支持该开源项目,以助力其持续发展。

Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Croc: 在两台计算机之间安全地传输文件和文件夹 (github.com/schollz) 10 点,由 gregsadetsky 发布于 2 小时前 | 隐藏 | 过往 | 收藏 | 1 条评论 帮助 turadg 4 分钟前 [–] 听起来像 Magic Wormhole (https://magic-wormhole.io/)。自述文件在最后提到了 Warner。 关键区别似乎是支持断点续传和代理支持。 另一个区别是它是单个二进制文件,而 MW 是用 Python 编写的,不过现在有了 https://github.com/magic-wormhole/magic-wormhole.rs。 我很欣赏该项目承认了其灵感来源。我希望项目在为那些试图进行选择的人提供与类似项目的详细比较时,能更加普遍。 回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

croc
Version Build Status GitHub Sponsors

This project’s future depends on community support. Become a sponsor today.

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
  • No need for local server or port-forwarding
  • IPv6-first with IPv4 fallback
  • Can use a proxy, like Tor

For more information about croc, see my blog post or read a recent interview I did.

Example

You can download the latest release for your system, or install a release from the command-line:

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

Using Homebrew:

Using MacPorts:

sudo port selfupdate
sudo port install croc

You can install the latest release with Scoop, Chocolatey, or Winget:

winget install schollz.croc

You can install the latest release with Nix:

You can add this to your configuration.nix:

environment.systemPackages = [
  pkgs.croc
];

First, install dependencies:

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

Install with pacman:

Install with dnf:

Install with portage:

Install with pkg:

Install with pkg:

On Linux, macOS, and Windows via Conda

You can install from conda-forge globally with pixi:

Or install into a particular environment with conda:

conda install --channel conda-forge croc

On Linux, macOS via Docker

Add the following one-liner function to your ~/.profile (works with any POSIX-compliant shell):

croc() { [ $# -eq 0 ] && set -- ""; mkdir -p "$HOME/.config/croc"; docker run --rm -it --user "$(id -u):$(id -g)" -v "$(pwd):/c" -v "$HOME/.config/croc:/.config/croc" -w /c -e CROC_SECRET docker.io/schollz/croc "$@"; }

You can also just paste it in the terminal for current session. On first run Docker will pull the image. croc via Docker will only work within the current directory and its subdirectories.

If you prefer, you can install Go and build from source (requires Go 1.22+):

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

There is a 3rd-party F-Droid app available to download.

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, run:

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.

Using croc on Linux or macOS

On Linux and macOS, the sending and receiving process is slightly different to avoid leaking the secret via the process name. You will need to run croc with the secret as an environment variable. For example, to receive with the secret ***:

For single-user systems, the default behavior can be permanently enabled by running:

You can send with your own code phrase (must be at least 6 characters):

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

Allow Overwriting Without Prompt

To automatically overwrite files without prompting, use the --overwrite flag:

croc --yes --overwrite <code>

To exclude folders from being sent, use the --exclude flag with comma-delimited exclusions:

croc send --exclude "node_modules,.venv" [folder]

Use Pipes - stdin and stdout

You can pipe to croc:

cat [filename] | croc send

To receive the file to stdout, you can use:

croc --yes [code-phrase] > out

To send URLs or short text, use:

croc send --text "hello world"

You can send multiple files directly by listing the files and/or folders:

croc send [file1] [file2] [file3] [folder1] [folder2]

To show QR code (for mobile devices), use:

croc send --qr [file(s)-or-folder]

You can send files via a proxy by adding --socks5:

croc --socks5 "127.0.0.1:9050" send SOMEFILE

To choose a different elliptic curve for encryption, use the --curve flag:

croc --curve p521 <codephrase>

For faster hashing, use the imohash algorithm:

croc send --hash imohash SOMEFILE

By default, the code phrase is copied to your clipboard. To disable this:

croc --disable-clipboard send [filename]

To copy the full command with the secret as an environment variable (useful on Linux/macOS):

croc --extended-clipboard send [filename]

This copies the full command like CROC_SECRET="code-phrase" croc (including any relay/pass flags).

To suppress all output (useful for scripts and automation):

croc --quiet send [filename]

You can run your own relay:

By default, it uses TCP ports 9009-9013. You can customize the ports (e.g., croc relay --ports 1111,1112), but at least 2 ports are required.

To send files using your relay:

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

Self-host Relay with Docker

You can also run a relay with Docker:

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

To send files using your custom relay:

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

To use custom ports, set CROC_PORTS (comma-separated) or CROC_PORT (base port):

docker run -d -p 9010-9011:9010-9011 -e CROC_PORTS='9010,9011' -e CROC_PASS='YOURPASSWORD' docker.io/schollz/croc

croc has evolved through many iterations, and I am thankful for the contributions! Special thanks to:

And many more!

联系我们 contact @ memedata.com