croc 是一种工具,可以让任何两台计算机简单安全地传输文件和文件夹。 AFAIK,croc 是唯一可以执行以下所有操作的 CLI 文件传输工具:
允许任意两台计算机传输数据(使用中继) 提供端到端加密(使用 PAKE) 实现轻松的跨平台传输(Windows、Linux、Mac) 允许多个文件传输 允许恢复被中断的传输 不需要本地服务器或端口转发 ipv6 优先和 ipv4 备用 可以使用代理,比如tor
在Linux上安装Croc工具
可以在 Bash 上使用以下命令将 croc 安装在所支持的任何 Linux 和 Unix 发行版上:
$ curl https://getcroc.schollz.com | bash
这个命令将把 croc 源码下载到本地并安装在 /usr/local/bin/ 目录下。 如果你不想直接注入Shell,可以从发行版页面下载预编译的二进制文件,并使用发行版的软件包管理器进行安装。 例如,在Ubuntu系统上可以使用以下命令安装 Croc deb 文件:
$ sudo apt install gdebi
$ sudo gdebi croc_8.3.2_Linux-64bit.deb
你可以使用 pacman 将 croc 安装在 Arch Linux 及其衍生版本中:
$ pacman -S croc
在 NixOS 上,执行以下命令进行安装:
$ nix-env -i croc
croc 也可用 snap 方式进行安装:
$ snap install croc
如果您已在 Linux 系统上安装了 Go 环境,也可以从源代码编译 croc 。
$ GO111MODULE=on go get -v github.com/schollz/croc/v8
使用Croc在计算机之间传输文件和文件夹
在使用之前,先确保在所有系统上都安装了 croc 。 要使用 croc 传输文件/文件夹,只需运行:
$ croc send
例:
$ croc send file.txt/pre>
croc 将生成如下的随机代码短语,相当于暗号。
Sending 'file.txt' (116 B)
Code is: slow-tomato-almond
On the other computer run
croc slow-tomato-almond
在这里,代码短语(暗号)是 slow-tomato-almond。该代码短语用于建立经过密码验证的密钥协议(PAKE),该协议会生成供发送方和接收方用于端到端加密的秘钥。
如果想要在另一台计算机上接收上述文件,那么收件人应输入上述输出的最后一行命令:
$ croc slow-tomato-almond
按 y,然后按回车键来接收文件。
Accept 'file.txt' (116 B)? (y/n) y
Receiving (
输出示例:
设置自定义代码短语
每次发送文件或文件夹时, croc 都会生成一个随机代码短语,但因为每次都不一样,使用起来还是不太方便。所以我们可以自定义一个代码短语,提高效率。可以使用 –code 参数来设置自定义代码短语来发送文件/文件夹。
$ croc send --code download-this file.txt
这里的download-this 就是我们自定义的代码短语。
输出示例:
Sending 'file.txt' (116 B)
Code is: download-this
On the other computer run
croc download-this
收件人可以使用以下命令接收文件(使用自定义的代码短语):
$ croc download-this
发送文本
就像文件和文件夹一样,我们也可以共享文本。当你要共享消息或者 URL 时可以用这种方式。
如果要使用 croc 发送文本,可以运行以下命令:
$ croc send --text "Hello!!"
输出示例:
Sending 'text'
Code is: natural-roof-clock
On the other computer run
croc natural-roof-clock
Sending (->[fe80::a00:27ff:fe10:7cc1%wlp9s0]:39916)
收件方需要使用以下命令获取文本:
$ croc natural-roof-clock
Accept 'text' ? (y/n) y
Receiving (
使用管道
你可以将文件的输出通过管道传输到 croc 作为它的输入,如下所示。
$ cat file.txt | croc send
输出示例:
Sending 'stdin' (116 B)
Code is: dexter-cowboy-soprano
On the other computer run
croc dexter-cowboy-soprano
croc 将自动使用 stdin 数据并发送文件,分配文件名,例如“ croc-stdin-728899651”。
在接收端,用户可以使用以下命令接收文件: 或者,使用: croc –yes dexter-cowboy-soprano > out 在这里,–yes 选项不会要求任何确认,并自动同意所有提示。
设置输出文件夹
默认情况下, croc 会将数据下载到当前工作目录中。您可以使用 –out 选项使其使用不同的下载位置。
$ croc send file.txt
输出示例:
Sending 'file.txt' (116 B)
Code is: program-public-mystery
On the other computer run
croc program-public-mystery
在接收端,运行:
$ croc --out ~/Downloads
出现提示时输入代码短语。
获得帮助
要获取帮助,请运行以下命令:
$ croc --help
NAME:
croc - easily and securely transfer stuff from one computer to another
USAGE:
Send a file:
croc send file.txt
Send a file with a custom code:
croc send --code secret-passphrase file.txt
VERSION:
v8.3.2-7d155ad
COMMANDS:
send send a file (see options with croc send -h)
relay start your own relay (optional)
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--remember save these settings to reuse next time (default: false)
--debug toggle debug mode (default: false)
--yes automatically agree to all prompts (default: false)
--stdout redirect file to stdout (default: false)
--no-compress disable compression (default: false)
--ask make sure sender and recipient are prompted (default: false)
--relay value address of the relay (default: "142.93.177.120:9009") [$CROC_RELAY]
--relay6 value ipv6 address of the relay (default: "[2604:a880:800:c1::14c:1]:9009") [$CROC_RELAY6]
--out value specify an output folder to receive the file (default: ".")
--pass value password for the relay (default: "pass123") [$CROC_PASS]
--help, -h show help (default: false)
--version, -v print the version (default: false)
以上就是良许教程网为各位朋友分享的Linu系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !