在 Mac OS X 上,如何加密一个小文件夹并将其复制到 Google Drive 或 DropBox?

non*_*ity 6 osx backup encryption

在 Mac OS X 上,现在我使用以下命令将一个小项目文件夹备份到 USB 闪存驱动器:

alias a='alias'
a dateseq='date "+%Y-%m-%d %H:%M:%S"'
a backup_proj='cp -a ~/code/MyProj "/Volumes/KINGSTON/MyProj `dateseq`"
Run Code Online (Sandbox Code Playgroud)

所以每次输入backup_proj,文件夹都会从硬盘备份到U盘,每个项目也是内部使用Git进行版本控制。每个文件夹只有大约500kb,所以即使填满1GB(闪存盘是16GB)也需要很长时间。该文件夹备份为:

$ ls -1 /Volumes/KINGSTON/
MyProj 2012-05-27 08:20:50/
MyProj 2012-05-27 10:27:56/
MyProj 2012-05-27 14:53:01/
Run Code Online (Sandbox Code Playgroud)

但我很偏执,也想备份到 Google Drive 或 Dropbox,这样它就会自动上传到他们的服务器,只需加密整个文件夹并将单个结果文件复制到 Google Drive 或 DropBox 的文件夹,密码可以是apple234321pineapple和在命令行中指定。我想知道有什么好方法可以将文件夹加密为单个文件,以便破解需要非实际时间?(能否请您提供可以执行此操作的命令行)。

Nor*_*ray 5

如果您使用gpg,那么您可以即时捆绑和加密,而无需指定密码。

% tar cf - MyProj | gpg -e -u 01234567 >/tmp/backup.tar.gpg
Run Code Online (Sandbox Code Playgroud)

这里,01234567是您要用于解密备份的密钥的 keyid。如果在您的 中~/.gnupg/gpg.conf,您将default-key参数设置为首选密钥的 keyid,那么您可以省略 -u 选项。

您可以类似地使用 .zip 压缩到标准输出zip - MyProj


Tim*_*Tim 4

man zip

从手册页:

-e --encrypt Encrypt the contents of the zip archive using a password which is entered on the terminal in response to a prompt (this will not be echoed; if standard error is not a tty, zip will exit with an error). The password prompt is repeated to save the user from typing errors.

另一种选择是 SSL 加密,例如:

openssl des3 -salt -pass pass:password -in file.txt -out encfile.txt

也许您可以在使用 openssl 加密文件夹之前先 TAR 该文件夹。

man openssl