mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-20 15:10:46 +02:00
rpcauth: Support storing credentials in a file
To be used with -rpcauthfile
This commit is contained in:
parent
98965fdadc
commit
6d69a2974b
@ -24,6 +24,7 @@ def main():
|
|||||||
parser = ArgumentParser(description='Create login credentials for a JSON-RPC user')
|
parser = ArgumentParser(description='Create login credentials for a JSON-RPC user')
|
||||||
parser.add_argument('username', help='the username for authentication')
|
parser.add_argument('username', help='the username for authentication')
|
||||||
parser.add_argument('password', help='leave empty to generate a random password or specify "-" to prompt for password', nargs='?')
|
parser.add_argument('password', help='leave empty to generate a random password or specify "-" to prompt for password', nargs='?')
|
||||||
|
parser.add_argument('--output', dest='output', help='file to store credentials, to be used with -rpcauthfile')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if not args.password:
|
if not args.password:
|
||||||
@ -35,6 +36,11 @@ def main():
|
|||||||
salt = generate_salt(16)
|
salt = generate_salt(16)
|
||||||
password_hmac = password_to_hmac(salt, args.password)
|
password_hmac = password_to_hmac(salt, args.password)
|
||||||
|
|
||||||
|
if args.output:
|
||||||
|
file = open(args.output, "x")
|
||||||
|
file.write(f'{args.username}:{salt}${password_hmac}')
|
||||||
|
print(f'Your password:\n{args.password}')
|
||||||
|
else:
|
||||||
print('String to be appended to bitcoin.conf:')
|
print('String to be appended to bitcoin.conf:')
|
||||||
print(f'rpcauth={args.username}:{salt}${password_hmac}')
|
print(f'rpcauth={args.username}:{salt}${password_hmac}')
|
||||||
print(f'Your password:\n{args.password}')
|
print(f'Your password:\n{args.password}')
|
||||||
|
Loading…
Reference in New Issue
Block a user