croc file transfer tutorial: cross-platform encrypted sending, breakpoint resumption and self-built relay

Introduces croc's method of encrypted file transfer between Windows, Linux and macOS, covering installation, password reception, directory and text transfer, breakpoint resume transfer, proxy and self-built relay.

To temporarily transfer a large file from Windows to Linux, common solutions require either logging into the cloud disk, configuring SSH, opening ports, or setting up a temporary HTTP service. croc reduces the process to sending a command and a phrase: the two ends establish a connection through a relay, and then use PAKE to derive keys for end-to-end encryption.

Supported by Windows, Linux, and macOS, croc can send a single file, multiple files, directories, or short text, and can continue an interrupted transfer. The default public relay is suitable for temporary use; you can also run your own relay when you have more stringent requirements for network boundaries, availability, or connection logging.

Quick Answer

The sender runs:

1
croc send report.zip

The terminal will display a receive phrase similar to example-code-phrase. The Windows receiver runs directly:

1
croc example-code-phrase

The current recommendation for Linux and macOS is to pass the password via an environment variable to avoid the password appearing in the process name:

1
CROC_SECRET=example-code-phrase croc

Accept the transfer after confirming that the sender, file name and size are correct. Do not post the receive phrase to group chats, tickets, or public logs; the person who gets the phrase may try to join the transmission.

why croc does not need port forwarding

By default, croc allows both the sender and the receiver to actively connect to the relay. Therefore, even if the two devices are behind different NATs or firewalls, there is usually no need to configure public IP addresses, inbound ports, or local servers.

The relay is responsible for assisting both ends in finding each other and forwarding data. The file content is end-to-end encrypted by the key generated by the sender and receiver through PAKE (Password-Authenticated Key Agreement, Password Authentication Key Agreement). The relay solves the connectivity problem, and the phrase participates in establishing an encrypted session shared by both parties.

This does not mean that password security can be ignored. The automatically generated phrase should be delivered to the recipient through a trusted channel, and the file information should still be verified before transmission. For sensitive environments, connection metadata, terminal history, clipboard and receive directory permissions visible to the relay should also be evaluated.

Install croc

Windows

Use WinGet:

1
winget install schollz.croc

You can also choose Scoop or Chocolatey:

1
scoop install croc
1
choco install croc

Check the version after installation is complete:

1
croc --version

macOS

Homebrew user runs:

1
brew install croc

Using MacPorts:

1
2
sudo port selfupdate
sudo port install croc

Linux

Arch Linux:

1
sudo pacman -S croc

Fedora:

1
sudo dnf install croc

If the release repository does not have a suitable version, you can download the corresponding file from the official Releases, or use the official installation script:

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

It is recommended to download and review the content before executing remote scripts on production devices. When Go 1.22 or higher is already installed, you can also install it from source:

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

Send files, directories and multiple items

Send a file:

1
croc send backup.tar.zst

Send the entire directory:

1
croc send project-assets

Send multiple files and directories at once:

1
croc send notes.md photo.jpg logs config

When sending the project directory, you can exclude unnecessary dependencies and virtual environments:

1
croc send --exclude "node_modules,.venv,.git" my-project

--exclude Receives comma separated names. It is best to confirm the exclusion range before transferring to avoid sending key files, environment variable files, caches and large dependency directories together.

Customize receiving phrase

The default random phrase is suitable for most situations. If you need to communicate by phone, etc., you can specify a phrase of at least six characters:

1
croc send --code correct-horse-27 report.zip

The custom phrase must be difficult enough to guess. Do not use project names, phone numbers, dates, or weak passwords like 123456. Phrases should only be given to the intended recipient and not reused in other documents after transmission.

Linux and macOS receivers recommend using this:

1
CROC_SECRET=correct-horse-27 croc

In a trustworthy single-user system, the behavior of taking phrases directly as parameters can be restored in the classic way:

1
croc --classic

The classic method is more convenient, but the password may be exposed to other processes or monitoring tools on the machine through process parameters. This setting is not recommended for servers shared by multiple people.

Send text, use pipes and QR codes

Send short text or URL:

1
croc send --text "https://example.com/download"

Send content from standard input:

1
cat result.json | croc send

Write directly to the file after receiving:

1
croc --yes example-code-phrase > result.json

When sending to the mobile phone, you can have the terminal display the QR code:

1
croc send --qr photo.jpg

The QR code also contains the information required to join the transmission and should not be displayed in public live streams, screenshots or recordings.

How to use breakpoint resume transfer

croc supports resuming interrupted transfers. After the network is disconnected, keep the original file at the sender and some files that have been written by the receiver, and then rerun the transfer process. When there are significant changes in the receive path, file contents, or relay conditions, recovery may not work as expected.

Pay attention to three points during actual operation:

  1. Do not delete or rename the unfinished files on the receiving end;
  2. Do not modify the sending source file before recovery;
  3. Confirm that the remaining space on the disk is enough to accommodate the complete file.

If recovery fails repeatedly, first use a small file to test the connectivity between both ends and the relay, and then check whether the versions are too different, whether the proxy is stable, and whether the security software intercepts the connection.

Transfer via SOCKS5 proxy

croc can specify a SOCKS5 proxy. For example, the native agent listens to 127.0.0.1:9050:

1
croc --socks5 "127.0.0.1:9050" send backup.tar.zst

Proxies affect connection paths and speeds, but do not replace the encryption of croc itself. Whether the receiving end also needs a proxy depends on its network environment. When troubleshooting, you should separately verify whether the proxy port, DNS processing method, and relay address are reachable.

Self-built croc relay

The easiest way is to run it directly on the server:

1
croc relay

By default, TCP port 9009-9013 is used. Provide at least two ports when customization is required:

1
croc relay --ports 1111,1112

The sender specifies a self-built relay:

1
croc --relay "relay.example.com:9009" send report.zip

Use Docker and set a password for relay:

1
2
3
4
5
6
docker run -d \
  --name croc-relay \
  --restart unless-stopped \
  -p 9009-9013:9009-9013 \
  -e CROC_PASS='CHANGE_THIS_PASSWORD' \
  docker.io/schollz/croc

Provide the relay address and password when sending:

1
2
3
croc --pass CHANGE_THIS_PASSWORD \
  --relay "relay.example.com:9009" \
  send report.zip

Before deployment, you need to release the actual TCP ports in the cloud firewall and host firewall. The relay password should not be written directly into a shared script, shell history, or public Compose file; it is more appropriate to inject it from a controlled environment variable or key management system.

A self-built relay can control relay location, access policy, and availability, but it cannot replace endpoint security. When the sending end is implanted with malicious programs, the receiving directory permissions are incorrect, or the phrase is leaked, self-built servers cannot solve these problems.

Parameters that require caution when automating

The following command skips confirmation and allows files with the same name to be overwritten:

1
croc --yes --overwrite example-code-phrase

It is suitable for automated tasks that are clearly controlled and not suitable for running casually in untrusted directories. The default confirmation prompt can help detect file name, size, or source anomalies. Do not enable both --yes and --overwrite unless the script has independently verified the receiving target.

Silent sending can be done using:

1
croc --quiet send report.zip

Silent mode reduces log output and may mask the cause of failure. The exit code should be checked at the same time in the scheduled task, and the error output should be written to the protected log.

Common troubleshooting

After inputting phrases at both ends, the connection has been unable to occur.

First confirm whether the croc version, system time and network access at both ends are normal, and then check whether the company’s firewall, proxy or operator blocks the relay port. You can try again with a small file to determine whether the problem comes from the connection or the file itself.

Running croc 短语 directly on Linux or macOS does not meet expectations

The new version recommends putting the phrase into CROC_SECRET:

1
CROC_SECRET=example-code-phrase croc

This is to reduce the risk of the phrase being leaked via the process name, not the installation failure.

A file with the same name already exists on the receiving end

Prioritize keeping the confirmation prompt and check the source before deciding whether to overwrite it. --yes --overwrite is only considered if the script has verified the file identity and target path.

Self-built relay can connect but cannot transmit

Verify that the entire port range is mapped and released, not just the first port. The default relay uses 9009-9013; when customizing the scope, the Docker mapping, host firewall, cloud security group, and croc startup parameters must be consistent.

Which scenarios is croc suitable for?

croc is very suitable for temporarily transferring files across platforms, remotely assisting users to export logs, transferring build products between devices without SSH accounts, and migrating directories from old computers to new computers. It does not require both parties to register accounts, nor does it require the receiving end to open an inbound port.

If long-term synchronization, version history, team rights management, or large-scale backups are required, Syncthing, object storage, rsync, or a dedicated backup system are often more suitable. croc is positioned to simplify one-time or short-term transfers, not to replace a complete data management solution.

Summary

croc compresses cross-network file transfer into three steps: “send file, share phrase, receive confirmation”, while retaining end-to-end encryption, cross-platform, breakpoint resume and self-built relay capabilities. Just use the default public relay for daily use; sensitive or controlled networks can deploy their own relays but still protect receive phrases, endpoint history, file permissions, and endpoint devices.

Project address: schollz/croc