Bitcoin Forum
June 06, 2024, 02:05:35 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: php works, bitcoin-cli not?  (Read 521 times)
dj5000 (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
December 22, 2016, 07:09:12 PM
 #1

Hi there,

I'm trying to set up a system for some specificv Penetration tests. So, I have an Hyper-V virtual machine running Ubuntu server 16.04.1 with Apache2(with PHP7) that accept request through Tor Hidden Service.
Also installed bitcoind with the conf:
server=1
listen=1
proxy=127.0.0.1:9050
rpcuser=myuser
rpcpassword=mypassword

bitcoind runs at boot from crontab.

Using easybitcoin.php "'library" I can see "getinfo", "sendtoaddress" etc.. tested with Tor browser bundle on an entirely different PC. so far so good.

The problem is that bitcoin-cli refuse to connect "cannot connect to server". I tried everything: user, root, using rpcuser & rpcpassword with the credentials in the conf, pointing to the conf, pointing to port, pointing to datadir, Nothing works!
Also tried to point it to the wrong port just to see if the error changes and it did, to 501.

What can I do to make it work?
Any Ideas?

Please Help!

Thanks
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3416
Merit: 6675


Just writing some code


View Profile WWW
December 23, 2016, 12:29:12 AM
 #2

Are you using a separate datadir? If so, you need to specify it in the bitcoin-cli command.

Additionally, try stopping Bitcoin Core and seeing a file in the datadir named .cookie (or something like that) exists. If it does, then delete the file and restart Core and try again.

Lastly, rpcuser and rpcpassword have been deprecated and replaced with cookie authentication. For cookie auth, you read the user and pass from the aforementioned file. This user and pass will change every time your restart Bitcoin Core. If you do want to continue to use rpcuser and rpcpassword, I suggest you instead use rpcauth. You can take a look at https://github.com/bitcoin/bitcoin/blob/44f2df613f23d0a095a6e47b3d9c498b9df3055b/share/rpcuser/rpcuser.py for help with creating the proper string for rpcauth.

dj5000 (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
December 23, 2016, 09:30:37 AM
 #3

Are you using a separate datadir? If so, you need to specify it in the bitcoin-cli command.

Additionally, try stopping Bitcoin Core and seeing a file in the datadir named .cookie (or something like that) exists. If it does, then delete the file and restart Core and try again.

Lastly, rpcuser and rpcpassword have been deprecated and replaced with cookie authentication. For cookie auth, you read the user and pass from the aforementioned file. This user and pass will change every time your restart Bitcoin Core. If you do want to continue to use rpcuser and rpcpassword, I suggest you instead use rpcauth. You can take a look at https://github.com/bitcoin/bitcoin/blob/44f2df613f23d0a095a6e47b3d9c498b9df3055b/share/rpcuser/rpcuser.py for help with creating the proper string for rpcauth.

That's interesting..

Ok, So I've killed the bitcoin process, deleted the cookie and rebooted.
Same result, in php it works but not in terminal/ssh with bitcoin-cli.
I previously tried specifying datadir... same results.
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1520


No I dont escrow anymore.


View Profile WWW
December 27, 2016, 06:39:42 AM
 #4

-snip-
Same result, in php it works but not in terminal/ssh with bitcoin-cli.
I previously tried specifying datadir... same results.

Does it work if you specifiy the full path to the bitcoin-cli? e.g. (your path may vary)

Code:
/usr/bin/bitcoin-cli getinfo

Im not really here, its just your imagination.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!