如何以相当快的速度粉碎 git 存储库?

Seb*_*ian 2 git data-recovery shred deleted-files

我有兴趣在合理的时间内准确删除 git 存储库。

但要做到这一点需要相当长的时间。在这里,我有一个小型测试存储库,其中.git文件夹 < 5MiB。

$ du -ac ~/tmp/.git | tail -1
4772    total
$ find ~/tmp/.git -type f | wc -l
991
Run Code Online (Sandbox Code Playgroud)

使用shred的默认选项,这需要相当长的时间。在下一个命令中,我用来--force更改权限并--zero在粉碎后用零覆盖。默认的粉碎方法是用随机数据覆盖3次(-n3)。

我还想稍后删除这些文件。根据man shred--remove=wipesync(默认情况下,当--remove使用时)仅对目录进行操作,但这似乎会减慢我的速度,即使我只对文件进行操作。比较(每次我重新初始化 git 存储库时):

$ time find ~/tmp/.git -type f | xargs shred --force --zero --remove=wipesync
real    8m18.626s
user    0m0.097s
sys     0m1.113s

$ time find ~/tmp/.git -type f | xargs shred --force --zero --remove=wipe
real    0m45.224s
user    0m0.057s
sys     0m0.473s


$ time find ~/tmp/.git -type f | xargs shred --force --zero -n1 --remove=wipe
real    0m33.605s
user    0m0.030s
sys     0m0.110s
Run Code Online (Sandbox Code Playgroud)

有更好的方法吗?


编辑:是的,加密是关键。我现在只是使用-n0.

time find ~/tmp/.git -type f | xargs shred --force --zero -n0 --remove=wipe    
real 0m32.907s
user 0m0.020s
sys     0m0.333s
Run Code Online (Sandbox Code Playgroud)

使用 64 个并行shreds

time find ~/tmp/.git -type f | parallel -j64 shred --force --zero -n0 --remove=wipe
real    0m3.257s
user    0m1.067s
sys     0m1.043s
Run Code Online (Sandbox Code Playgroud)

Gil*_*il' 5

算了shred,它花了很多时间做无用的事情而错过了本质。

\n\n

shred通过用随机数据多次覆盖文件来擦除文件(a \xe2\x80\x9cGutmannWipe\xe2\x80\x9d),因为使用 20\xe2\x80\x9330 年前的磁盘技术和一些昂贵的实验室设备,恢复被覆盖的数据是可能的(至少在理论上)。现代磁盘技术不再是这种情况:只用零覆盖一次也同样好 \xe2\x80\x94\xc2\xa0 但多次随机传递的想法在过时后仍然存在。请参阅https://security.stackexchange.com/questions/10464/why-is-writing-zeros-or-random-data-over-a-hard-drive-multiple-times-better-th

\n\n

另一方面,shred擦除敏感信息完全失败,因为它只擦除被告知要擦除的文件中的数据。存储在先前删除的文件中的任何数据仍然可以通过直接访问磁盘而不是通过文件系统来恢复。来自 git 树的数据可能不太容易重建;然而,这是一个现实的威胁。

\n\n

为了能够快速擦除某些数据,请对其进行加密。您可以使用ecryptfs(主目录加密)、encfs(目录树加密)、dm-crypt(全分区加密)或任何其他方法。要擦除数据,只需擦除密钥即可。

\n\n

另请参阅如何确定目录或文件确实已删除?

\n