I have my public & private key (generated with MyEtherWallet), however, I forgot to create a keystore file, which would make my online access to the wallet a bit safer if I'm correct.

I got to install geth.exe on my offline computer, and

geth account import e:\rawprivatekey.txt

works, but only returns the public address. I can't seem to get it to regenerate a keystore file! Does anyone know how to do that?

3 Answers 3


When you import a key in geth it automatically creates a json wallet.

You can list existing wallets with geth account list.

A list should be like this:

Account #3: {59cc3d2701a69e2f006a47e412092d1274f81d58} keystore:///home/ubuntu/.ethereum/keystore/UTC--2018-01-28T05-19-52.363512148Z--59cc3d2701a69e2f006a47e412092d1274f81d58

The file pointed by the keystore is your json wallet you can copy and rename to some other place.

  • hmm... I only get a list of 3 (same) addresses in the parantheses, but no keystore information along with it.. I have to add that I'm offline and using Windows. Maybe the Windows version of geth.exe is different.
    – richey
    Jan 28, 2018 at 23:04

With Web3.js

var Web3 = require('web3');
var web3 = new Web3(Web3.givenProvider || 'ws://some.local-or-remote.node:8546');
var JsonWallet = web3.eth.accounts.encrypt(privateKey, password);
  • isn't the private key communicated to the remote node? Oct 30, 2021 at 6:47

If you want to generate keystore file and you have a private key, you can use web3.py (^4.0.0b6).

There is a module called Account and in this module there is a method called encrypt.

Account.encrypt(private_key, password)

Creates a dictionary containing your private key, encrypted by the supplied password. If you want to create a keyfile recognized by Ethereum clients like geth and parity: encode this dictionary with json.dumps() and save it to disk where your client keeps key files.


Yes, web3.js doesn't have it, but web3.py does

  • ok, I can install python for it, but where to find web3.py? (sorry, noob here)
    – richey
    Jan 26, 2018 at 1:33
  • web3.py docs Quickstart. Jan 26, 2018 at 1:35
  • I, personally, use PyCharm, so I just go Settings > Project Interpreter > Install > web3 Jan 26, 2018 at 1:36
  • sorry, I can't figure it out. I have installed PyCharm on my offline computer now (the point I want to regenerate the keyfile is to avoid being forced to enter my private key in an online browser!), but web3.py isn't found that way. Guess it has to be loaded over the Internet (which it is offline from in my case). Can I manually add it somehow, or is there another method to regenerate the keystore file from the private key?
    – richey
    Jan 27, 2018 at 1:43
  • I’m afraid there are no other methods to recover keystore file. Jan 27, 2018 at 9:58

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.