when I use the web3 interface to sign on msgs, it tell me that the account should be unlocked, how can I manage this with geth and what exactly does unlocking mean?

up vote 39 down vote accepted

By default, your accounts in Geth are "locked," which means that you can't send transactions from them. You need to unlock an account in order to send transactions from it through Geth directly or via RPC (though web3 does not support this). In order to unlock an account, you'll need to provide the password, which is used to decrypt the private key associated with your account, hence allowing you to sign transactions.

With that being said, how do you unlock an account? There are a couple different ways you can do it, which are highlighted in the Geth documentation. I'll provide an overview:

  1. Unlock account when you run Geth. The password parameter is optional. If you don't provide it, you'll be prompted to type in the password.

    geth --unlock <YOUR_ACCOUNT_ADDRESS> --password <YOUR_PASSWORD>

  2. Unlock account from the Geth interactive Javascript console. Again, the password is optional. If you don't provide it, you'll be prompted to type it in. Note that in earlier versions of Geth, providing the password as a parameter would cause the password to show up in the Geth log, which may be a security concern.

    personal.unlockAccount(address, "password")

  • 7
    It should be noted that entering the password non-interactivly stores the password in plaintext in the console history. This should really not be used as it opens up an attack vector. – tayvano May 22 '16 at 2:06
  • 1
    geth --unlock is the way to do it, i guess web3 will log all of your inputs in log – niksmac May 22 '16 at 3:18
  • 3
    remove the brackets, then it should work: geth --unlock 0x3b3F14690C8Fb8b1B333Ff38961bdEEa658a3873 Not that this is prompting you for a password and the prompt for the password might be hidden somewhere in the mass of output during geth startup, e.g. Unlocking account 0xb2... | Attempt 1/3 Passphrase: I0522 12:30:46.360237 node/node.go:298] IPC endpoint opened: /home/someone/.ethereum/geth.ipc I0522 12:30:46.836509 p2p/nat/nat.go:111] mapped network port tcp:30303 -> 30303 (ethereum p2p) using UPNP IGDv1-IP11 (Try to find the word Passphrase in the above output ;) ) – Validity Labs - Sebastian May 22 '16 at 10:32
  • 2
    So if you can unlock it, how do you lock it again? :p – Kebman Aug 15 '17 at 21:23
  • 2
    @bshea Note that if you wish to use the automatic relock but don't want to pass your password as a parameter, you can also use personal.unlockAccount("address", undefined, 300) – Nulano Apr 4 at 15:43

Just to add to the excellent accepted answer.

You can also unlock the account from Web3 directly:

web3.personal.unlockAccount('0xE0ca...c1f7', 'mypass')

And lock it back:

web3.personal.lockAccount('0xE0ca...c1f7')

For more details refer to the web3-eth-personal module.

what exactly does unlocking mean?

A Geth node implementation contains built-in account management, that is, it maintains the account's private key, which is stored on disk in encrypted form. Unlocking an account means decrypting its private key and storing it in memory (it is never stored decrypted on disk).

⚠ This means you should take extra care not to allow anyone access your Geth node via HTTP-RPC, WS-RPC or IPC, because these interfaces allow transferring ether from any unlocked account! ⚠

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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