'How to safely delete public_keys created as part of `near login` flow?

i've been practicing with the near-cli as part of my personal project to automate some tasks, this requires running near login quite a few times in debugging. However, when i do near login it seems to create a new public key every time, as when I do near keys <account> from time to time I see this list grow. When I did near keys delete <public_key> to cleanup, it did give a warning about accidentally deleting the wrong public key, so I attempted dropping keys older than the last one entered, however running near login again gave an error that I had deleted the key that gave access thru the web login. (I kept the key value and did near keys add <public_key> to restore access.

My question is, how best do I keep track of which public_keys are safe to delete when experimenting with the CLI this way?



Solution 1:[1]

The simplest answer is: Make sure you always have one keypair left. Keys are stored in ~/.near-credentials, with files containing both the private and public part of the key. Always keep one of these files, and make you don't remove the corresponding key from the account.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 tifrel