# 交互式,输入密码 $ geth account new INFO [07-09|05:06:46.393] Maximum peer count ETH=25 LES=0 total=25 Your new account is locked with a password. Please give a password. Do not forget this password. Passphrase: Repeat passphrase: Address: {df90109c1497bc6f3a0cd98cdc114ec89481447e}
# 非交互式,从文件读取密码。不建议使用,容易暴露密码 $ geth --password /path/to/password account new # 例如 $ geth --password ethpasswd account new INFO [07-09|05:27:48.567] Maximum peer count ETH=25 LES=0 total=25 Address: {0ad31ccaf888cf8499de4cdfa18f8d746a1d27e7}
3.1.3. 查询账户
geth account list
1 2 3 4
$ geth account list INFO [07-09|05:29:31.708] Maximum peer count ETH=25 LES=0 total=25 Account #0: {df90109c1497bc6f3a0cd98cdc114ec89481447e} keystore:///root/.ethereum/keystore/UTC--2018-07-08T21-07-05.374654217Z--df90109c1497bc6f3a0cd98cdc114ec89481447e Account #1: {0ad31ccaf888cf8499de4cdfa18f8d746a1d27e7} keystore:///root/.ethereum/keystore/UTC--2018-07-08T21-27-48.567366972Z--0ad31ccaf888cf8499de4cdfa18f8d746a1d27e7
$ cd .ethereum/keystore $ ls UTC--2018-07-08T21-07-05.374654217Z--df90109c1497bc6f3a0cd98cdc114ec89481447e UTC--2018-07-08T21-27-48.567366972Z--0ad31ccaf888cf8499de4cdfa18f8d746a1d27e7
$ geth account update df90109c1497bc6f3a0cd98cdc114ec89481447e INFO [07-09|06:02:53.411] Maximum peer count ETH=25 LES=0 total=25 Unlocking account df90109c1497bc6f3a0cd98cdc114ec89481447e | Attempt 1/3 Passphrase: INFO [07-09|06:02:57.475] Unlocked account address=0xdF90109c1497bc6f3a0cd98cdC114Ec89481447E Please give a new password. Do not forget this password. Passphrase: Repeat passphrase:
也可以通过账户索引来修改密码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# 以下示例的账号索引为 0 $ geth account update 0 INFO [07-09|06:05:59.087] Maximum peer count ETH=25 LES=0 total=25 WARN [07-09|06:05:59.087] ------------------------------------------------------------------- WARN [07-09|06:05:59.087] Referring to accounts by order in the keystore folder is dangerous! WARN [07-09|06:05:59.087] This functionality is deprecated and will be removed in the future! WARN [07-09|06:05:59.087] Please use explicit addresses! (can search via `geth account list`) WARN [07-09|06:05:59.087] ------------------------------------------------------------------- Unlocking account 0 | Attempt 1/3 Passphrase: INFO [07-09|06:06:04.081] Unlocked account address=0xdF90109c1497bc6f3a0cd98cdC114Ec89481447E Please give a new password. Do not forget this password. Passphrase: Repeat passphrase:
可以通过--password参数修改,仍需要输入文件中的密码:
1 2 3 4 5 6 7 8
geth --password ethpasswd account update 0ad31ccaf888cf8499de4cdfa18f8d746a1d27e7 INFO [07-09|06:10:16.564] Maximum peer count ETH=25 LES=0 total=25 Unlocking account 0ad31ccaf888cf8499de4cdfa18f8d746a1d27e7 | Attempt 1/3 Passphrase: INFO [07-09|06:11:04.954] Unlocked account address=0x0AD31CcAf888Cf8499de4cdFA18F8d746A1d27E7 Please give a new password. Do not forget this password. Passphrase: Repeat passphrase: