Author

Topic: Having trouble with wallet.dat when generating with walletupdate over json-rpc (Read 1013 times)

newbie
Activity: 5
Merit: 0
Ok now after some days of trouble I get the solution which works with less work and best for me.

I let the bitcoind running under root, then I called the json-rpi command walletbackup which saves the wallet.dat in the directory which the webserver also uses (/var/www).

The owner and rights for the directory ( and wallet.dat ) I changed with a cronjob over the crontab which is called every minute.

 
Code:
crontab -e // logged as root

insert the following into the crontab file:

Code:
* * * * * /bin/chown -R >>your needed username<< /var/www/your file directory

press ESC
type :wq

Thats it.

staff
Activity: 3458
Merit: 6793
Just writing some code
Now on ssh starting the bitcoin daemon it shows:

Bitcoin server starting
$ Error: To use bitcoind, or the -server option to bitcoin-qt, you must set an
rpcpassword in the configuration file:
/var/www/.bitcoin/bitcoin.conf
It is recommended you use the following random password:
....

So I should put a bitcoin.conf in the /var/www/ directory, right?
You should actually move the .bitcoin folder from its current location to that folder. It should be in /root use chown to change the owner of the entire directory to be www-data. Use -R so that it does it for all files and directories in the folder.
newbie
Activity: 5
Merit: 0
Now on ssh starting the bitcoin daemon it shows:

Bitcoin server starting
$ Error: To use bitcoind, or the -server option to bitcoin-qt, you must set an
rpcpassword in the configuration file:
/var/www/.bitcoin/bitcoin.conf
It is recommended you use the following random password:
....

So I should put a bitcoin.conf in the /var/www/ directory, right?
staff
Activity: 3458
Merit: 6793
Just writing some code
That would be the simplest way, but the user www-data was created by installation of apache I think, so I don´t know where to find the password for www-data - and if I change the password over ssh I don´t know if the apache works well. Maybe you have a idea if there´ll be any trouble when changing/setting the password.
You can't sign in as www-data. Instead, login as root and type the following command:
Code:
su - www-data
That should change your user to www-data. Then just run bitcoind normally.
newbie
Activity: 5
Merit: 0
That would be the simplest way, but the user www-data was created by installation of apache I think, so I don´t know where to find the password for www-data - and if I change the password over ssh I don´t know if the apache works well. Maybe you have a idea if there´ll be any trouble when changing/setting the password.
staff
Activity: 3458
Merit: 6793
Just writing some code
@knightdk - Yes thats the manual way, but I don´t want to do this over ssh every time when I make a backup -  so the controlling should be only over the local webserver.

I search for a way to do this without write a program. Whats about a chronjob?
You could use a cronjob to execute a script. It could run periodically to both backup the wallet and change the owner.

Actually, why don't you just restart the bitcoind as user www-data? Then the back up file will also be owned by www-data. You would only need to change the owner of all of the files in the datadir to be www-data.
newbie
Activity: 5
Merit: 0
@knightdk - Yes thats the manual way, but I don´t want to do this over ssh every time when I make a backup -  so the controlling should be only over the local webserver.

I search for a way to do this without write a program. Whats about a chronjob?
staff
Activity: 3458
Merit: 6793
Just writing some code
ssh into your server and use the chown command to change the owner of the wallet.dat to be www-data. In the /www folder, the command should be run as root, since root is the owner, and it should look like this
Code:
chown www-data:www-data wallet.dat

Now I really hope your wallet is encrypted because anyone who can access that webserver can download your wallet file.
newbie
Activity: 5
Merit: 0
Hi everybody,
I´m setup a local webserver with apache + bitcoind and have a general problem with the permissions of the wallet.dat backup which I generated with walletbackup command over the json-rpc and saved in the /www directory to access and download them over the client. Now my bitcoind is running under root, so the backupfile gets the same rights. So I have no access over the cient to this file because the apache uses the "www-data" user for this /www directory.

 Is there any secure way to change the user or group of the backup file? Or should I run bitcoind under a other user?

Thanks for helpful comments.
Jump to: