Manage your EOS account keys with Docker, cleos and keosd

in #eos6 years ago (edited)

Overview

How to change/manage your EOS keys (owner/active) from the command line using the official Docker image from EOSIO.

This is a very techincal post, if you prefer a UI you could check out the greymass wallet.

You'll need your private key from your existing EOS account to make these updates.

TL;DR

  1. Run keosd with Docker
  2. Set a cleos alias to execute commands inside the docker container using your local keosd instance
  3. Run a bunch of command line operations

Process

This post was written at the time of EOS version 1.2.2.

The following steps are done using bash or zsh using Linux, should also run on OSX and Windows with the appropriate software installed (Docker, bash/zsh).

Start a docker container using the offical eos-dev image from eosio:

docker run --rm --name keosd -it -v ~/eosio-wallet:/tmp/eosio-wallet eosio/eos-dev keosd --wallet-dir /tmp/eosio-wallet

Note: You don't need to mount a volume if you don't want to keep your wallet around.

Create an alias to run the cleas commands inside the docker container:

alias cleos='docker exec -it keosd /opt/eosio/bin/cleos -u http://eos.greymass.com --wallet-url http://127.0.0.1:8888'

Set an environment variable with your EOS account name so we can reuse it easily:

export ACCOUNT_NAME=*************

Check it's all working, get your account details:

cleos get account $ACCOUNT_NAME

List wallets (we have none yet):

cleos wallet list

Create a wallet:

cleos wallet create -n $ACCOUNT_NAME --to-console

Save the password for the wallet, we'll be using it again.

Import the existing owner key to the wallet.

Note: there's a space at the start of commands with our priviate keys so they don't save to history:

cleos wallet import -n $ACCOUNT_NAME --private-key ************

List keys:

cleos wallet keys

Create a new owner key and save it with your encryption software:

cleos create key --to-console

Create a new active key and save it with your encryption software:

cleos create key --to-console

Set the new active key, replace EOS******* with your public active key

cleos set account permission $ACCOUNT_NAME active EOS******* owner -p $ACCOUNT_NAME@owner

Set the new owner key, replace EOS******* with your public owner key

cleos set account permission $ACCOUNT_NAME owner EOS******* -p $ACCOUNT_NAME@owner

List keys:

cleos wallet keys

The current local wallet key is now change, remove it:

cleos wallet remove_key -n $ACCOUNT_NAME EOS*******

We want to vote, or re-vote to avoid vote decay. Add the private key of your new active key to your wallet:

cleos wallet import -n $ACCOUNT_NAME --private-key PRV************ACITVE_KEY

Vote. In this example we use a proxy:

cleos system voteproducer proxy $ACCOUNT_NAME investingwad

Optional: clean up / reset.

List keys:

cleos wallet keys

cleos wallet remove_key -n $ACCOUNT_NAME EOS*******

References

Thanks to cc32d9 for the kickstart.

Coin Marketplace

STEEM 0.30
TRX 0.26
JST 0.039
BTC 95213.51
ETH 3406.88
USDT 1.00
SBD 3.49