Croc: Easily and securely send things from one computer to another



Version
Coverage
Build
Status

This project is supported by Github sponsors.

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 or read a recent interview I did.

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:

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, Chocolatey, or Winget:

winget install schollz.croc

On Unix you can install the latest release with Nix:

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:

On Fedora you can install with dnf:

On Gentoo you can install with portage:

On Termux you can install with pkg:

On FreeBSD you can install with pkg:

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

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

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 

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 

Available curves are P-256, P-348, P-521 and SIEC. P-256 is the default curve.

Change hash algorithm

You can choose from several different hash algorithms. The default is the xxhash algorithm which is fast and thorough. If you want to optimize for speed you can use the imohash algorithm which is even faster, but since it samples files (versus reading the whole file) it can mistakenly determine that a file is the same on the two computers transferring – though this is only a problem if you are syncing files versus sending a new file to a computer.

croc send --hash imohash SOMEFILE

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:

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, or ask a question.

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!

Note: This article have been indexed to our site. We do not claim legitimacy, ownership or copyright of any of the content above. To see the article at original source Click Here

Related Posts
How To Access Your Link History On Facebook Mobile thumbnail

How To Access Your Link History On Facebook Mobile

pixinoo/Shutterstock The longer social media sticks around, the more each platform finds increasingly uncomfortable ways to track your information, store your engagement history, and ultimately pander to you with tailored ads. In fact, if you performed a deep dive into what platforms like Facebook have stored and deduced about you, it would likely be horrifying.
Read More
By mid-2022, the number of SpaceX reusable Dragon spacecraft will increase to eight thumbnail

By mid-2022, the number of SpaceX reusable Dragon spacecraft will increase to eight

10月8日消息,当地时间周四,美国宇航局(NASA)官员和SpaceX代表在载人龙飞船第三次商业宇航员发射任务(Crew-3)前举行了简报会,透露了该公司计划建造和使用可重复使用龙飞船支持NASA任务的详细情况。 图1:到2022年中期,SpaceX可重复使用的龙飞船数量将增加到八艘在简报会上,SpaceX龙飞船任务管理总监莎拉·沃克(Sarah Walker)透露,该公司将使用全新载人龙飞船(C210)执行Crew-3任务,该飞船将被重复使用的猎鹰9号火箭助推器B1067送入太空。B1067于2021年6月3日首次亮相,当时将SpaceX第二艘升级后的货运龙飞船送往国际空间站。Crew-3任务将是NASA第二次用回收的商业火箭发射宇航员。2021年4月,SpaceX首次用回收猎鹰9号火箭助推器(B1062)发射NASA宇航员,执行所谓的载人龙飞船第二次商业宇航员发射任务(Crew-2)。Crew-2载人龙飞船也曾进入过轨道,支持SpaceX在2020年5月进行的首次载人试飞。五个月后,SpaceX成功完成了世界上首次纯商业太空载人飞行任务Inspiration4。当时,该公司使用回收的助推器发射了重复使用的载人龙飞船。随着SpaceX首次使用经过两次回收的猎鹰9号火箭执行载人任务,载人龙飞船的可重复使用性进一步提升。图2:2021年1月,载人龙飞船C207首次在轨道上飞行执行Crew-3的C210将成为SpaceX第三艘投入运营的载人龙飞船,目前该公司正使用C206(奋进号)和C207(坚韧号)执行载人任务。沃克还证实,最近计划于2022年4月发射的Crew-4,也将使用新建的载人龙飞船。到2022年中期,该公司载人龙飞船将增加到四艘。这四艘飞船都将获得NASA至少五次飞行任务的认证,这应该能够满足NASA近期对载人龙飞船的需求。然而,如果无法获得超过五次飞行的长期认证,或者该公司在2030年之前继续让专业宇航员和普通人搭乘载人龙飞船飞行,那么它可能需要更多的飞船。但从理论上讲,如果波音公司的星际线飞船最终在2023年投入使用,而NASA继续运营国际空间站到2030年甚至更久,那么到2023年,SpaceX将只需每年为NASA执行一次载人发射任务即可。图3:2021年4月,载人龙飞船C206第二次抵达国际空间站在货运方面,沃克透露,SpaceX将于2021年12月和2022年5月在其CRS-24和CRS-25任务中首次亮相另外两艘新建的货运龙飞船,使该公司的货运飞船增加到四艘。只要国际空间站继续运行,SpaceX很可能会继续为其运送补给。从现在到2030年,该公司需要再发射大约12到18次货运龙飞船。不过,当SpaceX星际飞船投入使用,并获得NASA日常人员和货运任务认证后,星际飞船可能很快就会取代龙飞船。但这个里程碑可能还需要几年时间才能实现,这意味着SpaceX龙系列飞船至少在未来5到10年内需要继续充当顶梁柱。由此看来,SpaceX的可重复使用的龙飞船数量(包括载人和货运)有望在未来8个月内翻一番,从四艘增加到八艘。
Read More
Index Of News
Total
0
Share