This is such a basic question, but I can not figure out how to import a plain, unencrypted private key into geth or mist?

I tried geth account import 7[......]bla but it seems this command is always looking for an unencrypted keyfile.

Any ideas?

up vote 45 down vote accepted

Paste the key into a text file, save it to disk and use the path to that file with geth account import. Here are some example Windows instructions that might help:

  1. Open Notepad
  2. Paste key into notepad without any extra characters or quotations
  3. Save the file as nothing_special_delete_me.txt at C:\
  4. Run the command, geth account import C:\nothing_special_delete_me.txt
  5. After successful import, delete the file at C:\nothing_special_delete_me.txt

If you do not have geth installed already, do the following steps after step 3, and the continue to step 4:

  • Open command prompt (cmd.exe).
  • Inside the Command Prompt, type the following command to go to the folder containing your Geth.exe file: cd c:\Ethereum-Wallet-win64-0-7-3\resources\node\geth (insert your correct path there)
  • I am getting Fatal: keyfile must be given as argument while doing the same. PS: I am running on linux macine. – Prashant Prabhakar Singh Oct 10 '16 at 9:02

Use the following command in the geth console

web3.personal.importRawKey("<Private Key>","<New Password>")

Mist has no way to import via GUI, so you need to import using command line (geth). It will show up in your Mist immediately.

For Mac:

  1. Open TextEdit

  2. Paste key into TextEdit without any extra characters or quotations

  3. Save the file as nothing_special_delete_me.txt to your Desktop

  4. Open Terminal, run command:

    geth account import ~/Desktop/nothing_special_delete_me.txt
    
  5. After successful import, delete the file from your desktop.

  • "Paste the key into a text file" ... how can I see my private key before copy/paste it somewhere? In the Mist there is no option to take such an information? – user1770 Apr 28 '16 at 7:15
  • @metafl - if you have the account in mist then you don't need to import it into geth. It's already there . this explains where your mist keys are, but they are not raw private keys, they are encrypted keystore files. ethereum.stackexchange.com/questions/946/… – tayvano Apr 28 '16 at 9:07
  • bash users: a one-step answer is here. – Tom Hale Oct 24 '17 at 2:59
  • @TomHale The reason that it is recommended to use an external file is that doing it this way would store your private key in your .bash_history, which is unexpected for most and potentially bad – tayvano Nov 12 '17 at 0:24

For Linux:

when you download the mist wallet, you'll get a folder. Inside the folder is where the mist wallet is. After you run the mist wallet, you need to get on cli.

Go to /whereveryousavedtheetherumfolder/node/resource/geth/ then run ./geth account import privekey-file.txt.

  • This doesn't work in my case, I get Fatal: keyfile must be given as argument> I am still unable to resolve it. – Prashant Prabhakar Singh Oct 21 '16 at 5:53

Noting the popularity of this question I went ahead and built a tool such that if you have your raw private key, you can easily convert it into its public key counterpart and the derived Ethereum address.

You can then export the key in the appropriate format as defined here such that it can be utilised with Geth or Parity.

Input your private key enter image description here

Export your keyfile enter image description here

That said, I think it is worth noting that you should not be working with your private key directly anyway. Your private key controls access to your account.

  • 2
    NOTE: When using tools like this one, sending your private key to any 3rd party gives them full access to the contents of your wallet. – BadPirate Dec 31 '17 at 16:45
  • That is not strictly true. If we saved your private key then we would have access to your account. We do NOT save your private key. The point still stands though - you should always be cautious and careful with your private key. – Thomas Clowes Dec 31 '17 at 17:26

Only use this method for throw-away, testing accounts since your key will be stored in your shell's history (thanks to @tayvano).

Using bash, where abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca is your private key:

geth account import <(echo abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca)
  • 2
    The reason that it is recommended to use an external file is that doing it this way would store your private key in your .bash_history, which is unexpected for most and potentially bad – tayvano Nov 12 '17 at 0:24

protected by Community May 8 '16 at 0:01

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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