When interacting with EOS mainnet, especially at its early stage, you may suspect that your private key could be leaked. For example, you pasted it into a web application that you don’t fully trust.
With the cleos
command-line tool, you can easily change the private key for your account in a short time and at no cost. You would, however, need to compile it on your Linux machine using the build instructions.
The operation is two-step, as you need to replace the owner and active key authorizations. Key access to an account is defined by its permissions (which we are going to modify with the below commands).
# create a new keypair
cleos create key# example the keys created:
# Private key: 5HpyL****
# Public key: EOS6wNAR****# unlock your wallet with the old key
cleos wallet unlock# Now issue two transactions that modify the active
# and owner keys:cleos -u https://eos.greymass.com/ set account permission MYACCOUNT active EOS6wNAR**** owner -p MYACCOUNT@ownercleos -u https://eos.greymass.com/ set account permission MYACCOUNT owner EOS6wNAR**** -p MYACCOUNT@owner
Now you can save your new keys in a secure place and discard the old keys. You can also remove the old key from your wallet and import the new one:
cleos wallet remove_key OLDPUBKEY
# add space in front of the command, so that it does not get
# into bash history
cleos wallet import 5HpyL****