json rpc – bitcoin-cli cannot find RPC credentials
The “accepted answer” is technically correct, but its reasoning is incorrect and it doesn’t explain that there are actually two RPC authentication methods for bitcoind (which communicates with bitcoin-cli).
The command line -rpcuser and -rpcpassword are not for the rpcauth account. This is the first issue that isn’t mentioned in the accepted answer.
I also forgot to mention that rpcauth credentials cannot be used in the bitcoin-cli command line app. Bitcoind has two RPC authentication methods, only one of which can be used via the command line, and this is the old method that will be removed. After that it was ruined. There is no longer command line access to bitcoind via bitcoin-cli (there’s a sense…). As far as I can tell, you don’t have to use bitcoin-cli, you have to create your own script and connect via RPC port.
For now, you will need to use rpcuser and rpcpass from the command line or the bitcoin.conf file. Perhaps rpcauth support will be added to the command line in the future. But at the moment it doesn’t look like that’s going to happen.
Anyway, if anyone can actually show me a real answer to this (using rpcauth in the bitcoin-cli command line app), feel free. There is currently no way to use rpcauth from the command line bitcoin-cli. https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py appears to replace this, but currently all it does is generate passwords. In fact, as long as you use a pre-built command line app to communicate with bitcoind, this is pretty useless.