使用 cli 密码保护文件/文件夹

Tar*_*run 3 password

我有一些重要的文件需要保护,以免其他人访问我的机器。

问题是其他人可以通过 root 帐户访问我的机器,因此更改文件权限对我来说不是一个选择。我见过像 cryptkeeper 这样的应用程序,但我想知道我可以在 ubuntu 中通过命令行模式密码保护我的文件/文件夹。

Nic*_*Tux 6

如果其他用户对系统具有 root 访问权限,那么我可以看到保护您的文件/文件夹的唯一方法是加密和解密。

此处(在 AskUbuntu 中)列出了许多关于 encrypt/decrypt 的答案,但在我看来,我将展示最简单的方法。

开放式SSL

加密/解密文件

openssl aes-256-cbc -in file -out file.aes
openssl aes-256-cbc -d -in file.aes -out file
Run Code Online (Sandbox Code Playgroud)

OpenSSL 和 Tar

加密/解密文件夹

tar -zcf - directory | openssl aes-256-cbc -out directory.tar.gz.aes
openssl aes-256-cbc -d  -in directory.tar.gz.aes | tar -xz -f -
Run Code Online (Sandbox Code Playgroud)

将您的解密密码放在视线之外,也远离系统。