2

I have a file containing a private key that I want to securely delete.

Several sites as well as Claude suggest using rm -P but the man page of rm says:

This flag has no effect.

There was also a suggestion about "Secure empty the trash" which is an option that has been removed.

Is there a simple way to securely delete the file (preferrably from the command line)?

1
  • 2
    This is why disk encryption is a thing. Is FileVault on?
    – benwiggy
    Commented Aug 29 at 14:06

2 Answers 2

4

The topic has come up before (e.g. Secure delete removed in OSX 10.11, Is using the rm -P command safe on Macs with an SSD).

From a comment there:

The (modern) SSDs, when the get a delete command, don’t delete the data, the block is marked “unused” so it will be overwritten by new data relatively quickly. However, if it gets a read command for that block, it will return zeros or garbage. The problem comes in where “enterprise grade” hardware like caching controllers hold data. It could technically remain accessible which is why using encryption is highly encouraged. Thing is, the controller isn’t holding the whole SSD in cache (why would you need a drive, then?) But data could technically be accessed.

So, the way SSDs work, there is no value in overwriting files before deleting (what -P would do) because a block becomes basically unreadable if it is not used.

2

OTOH if your file is saved somewhere other than an SSD...

Apple has seen fit to remove the -P option from the version of rm they supply with recent versions of macOS; since 10.11 El Capitan. As is the case with many of the command line tools that Apple ships with macOS, the rm utility was "adopted" from FreeBSD (due to FreeBSD's generous license), and subsequently modified by Apple to remove the -P option.

However - you can still get srm (secure rm) from MacPorts.

srm has five (count 'em - 5) overwrite modes that can be specified as an option on the command line: --dod, --doe, --openbsd, --rcmp, --gutmann. So, if you need/want it, it's available from MacPorts.

As an aside, there's an interesting Wikipedia article on srm.

7
  • 1
    But see reddit.com/r/linux4noobs/comments/d7o7im/…
    – Barmar
    Commented Aug 30 at 21:19
  • @Barmar: Yeah - I'm not taking a side in the "should I" question... only trying to address the "how can I" question. I'm not smart enough to know the answer (if it exists); and I'm not certain anyone writing on reddit (or here ftm) is smart enough either.
    – Seamus
    Commented Aug 30 at 22:05
  • The point is that it doesn't really work, particularly on SSD.
    – Barmar
    Commented Aug 30 at 22:14
  • @Barmar: By "doesn't work", you obviously do not mean that "it does not do what it claims".
    – Seamus
    Commented Aug 30 at 22:17
  • 1
    No, missed that, sorry.
    – Barmar
    Commented Aug 30 at 22:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .