The geth init --datadir node/ genesis.json command generates an empty keystore directory and a geth directory. Its only after running the node that the geth folder is populated with the nodekey. Is it possible to generate the node.key file via the geth init command? Appreciate any help!


You can use the bootnode utility for this to create a nodekey immediately after geth init. You can download it with "Geth & Tools" from https://geth.ethereum.org/downloads/

bootnode -genkey <datadir>/geth/nodekey

If you wish to get the public key for the enode url, you can use:

bootnode -nodekey <datadir>/geth/nodekey -writeaddress
| improve this answer | |
  • How is this method using geth init? It just generates a private key and gives the public key for it. Can you tell how this can be applied on the node's directory after running geth init genesis.json? Or any other method? – thehandle Jan 26 '19 at 5:48
  • When you start the node it will take the datadir/geth/nodekey file. So you can just create it infront with bootnode. I've edited the answer. Hope it helps. – ivicaa Jan 26 '19 at 5:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.