'Difference between: `ssh-add -d ~/.ssh/some_key` and `rm ~/.ssh/some_key`?

Context

I am not actually facing this challenge, however, I was initially not successful at deleting an entry from the ssh-agent -l list while using the command:

ssh-add -d ~/.ssh/some_public_ssh_key_file.pub

The output was:

Could not remove identity "/Users/user/.ssh/some_public_ssh_key_file": agent refused operation

I learned thanks to this answer that it does work after I deleted both ssh keys of the pair:

~/.ssh/some_public_ssh_key_file
~/.ssh/some_public_ssh_key_file.pub

So then I thought, what if you delete those file before you removed the entry using their filenames using ssh-add -d ~/.ssh/some_public_key_file.pub? Will you have to delete all entries using killall ssh-agent or would you still be able to do that with specificity. However, the second time around I noticed that directly after deleting a key pair with:

rm ~/.ssh/some_public_ssh_key_file
rm ~/.ssh/some_public_ssh_key_file.pub

that the ssh-add -l output is:

The agent has no identities.

That makes me wonder:

Question

What is the difference between using:

ssh-add -d ~/.ssh/some_public_ssh_key_file

and:

rm ~/.ssh/some_public_ssh_key_file
rm ~/.ssh/some_public_ssh_key_file.pub

and is there a preferred option for some reason?

ssh


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source