如何用bash覆盖文件中的数据
我正在编写一个 bash 脚本来加密文件夹或文件的数据
#!/bin/bash
file_name=$1
tmp_file=/tmp/tmpfile.tar
# tar compress file
tar -cf $tmp_file $file_name;
# encrypt file
gpg -c $tmp_file
# remove temp file
rm -rf $tmp_file $file_name
# mv encrypted file to orignal place
mv ${tmp_file}.gpg $file_name
,但数据仍然可以通过使用 photorec 或类似方法恢复...
有没有办法确保绝对删除bash 中的原始文件?
I'm writing a bash script that encrypts the data of a folder or file
#!/bin/bash
file_name=$1
tmp_file=/tmp/tmpfile.tar
# tar compress file
tar -cf $tmp_file $file_name;
# encrypt file
gpg -c $tmp_file
# remove temp file
rm -rf $tmp_file $file_name
# mv encrypted file to orignal place
mv ${tmp_file}.gpg $file_name
but the data will still be recoverable by using photorec or similar methods...
Is there a way to ensure the absolute deletion of the original file in bash?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以尝试 srm 或 擦除
you can try srm or wipe
我认为不可能将文件通过管道传输到 gpg 中,因为您已经尝试过了?
I gather it is impossible to just pipe the file into gpg, as you would already have tried that?
这也应该有效:
This should also work:
您可以创建一个 ramdisk 来创建临时文件吗?或者,如果数据如此敏感,也许您应该使用加密的文件系统?
Can you create a ramdisk to create the temp file in? Alternatively if the data is that sensitive maybe you should be using an encrypted file system?