0
Entering the rpc credentials directly fails, as follows:
herbert@Spencer:~/bitcoin-0.18.0/bin$ ./bitcoin-cli -testnet -rpcconnect=127.0.0.1 -rpcuser=x -rpcpassword=p getblockchaininfo error: Authorization failed: Incorrect rpcuser or rpcpassword
whereas picking them up indirectly succeeds:
herbert@Spencer:~/bitcoin-0.18.0/bin$ ./bitcoin-cli -conf=/home/herbert/.bitcoin/bitcoin.conf -datadir=/home/herbert/.bitcoin getblockchaininfo
{
"chain": "test",
"blocks": 1576504,
"headers": 1576504,
"bestblockhash": "00000000318a0aa170e250d72d2973b4af97812c2c2704a457ce2e7bcbb8c8df",
...
The .conf file is minimal:
testnet=1 server=1 rpcusername=x rpcpassword=p
it's definitely being picked up from the right place - hence the fact that bitcoin runs in testnet mode.
It is probably better to switch to using
rpcauthasrpcuserandrpcpasswordare (soon?) deprecated. – Bjarne – 2019-08-31T13:59:24.933