Title: Having trouble with wallet.dat when generating with walletupdate over json-rpc Post by: bernd83 on July 21, 2015, 09:20:14 PM 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. Title: Re: Having trouble with wallet.dat when generating with walletupdate over json-rpc Post by: achow101 on July 22, 2015, 01:29:46 AM 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. Title: Re: Having trouble with wallet.dat when generating with walletupdate over json-rpc Post by: bernd83 on July 22, 2015, 03:19:24 AM @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? Title: Re: Having trouble with wallet.dat when generating with walletupdate over json-rpc Post by: achow101 on July 22, 2015, 03:47:50 AM @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. You could use a cronjob to execute a script. It could run periodically to both backup the wallet and change the owner.I search for a way to do this without write a program. Whats about a chronjob? 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. Title: Re: Having trouble with wallet.dat when generating with walletupdate over json-rpc Post by: bernd83 on July 22, 2015, 03:57:18 AM 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.
Title: Re: Having trouble with wallet.dat when generating with walletupdate over json-rpc Post by: achow101 on July 22, 2015, 04:07:01 AM 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 Title: Re: Having trouble with wallet.dat when generating with walletupdate over json-rpc Post by: bernd83 on July 22, 2015, 04:21:44 AM 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? Title: Re: Having trouble with wallet.dat when generating with walletupdate over json-rpc Post by: achow101 on July 22, 2015, 05:54:35 AM Now on ssh starting the bitcoin daemon it shows: 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.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? Title: Re: Having trouble with wallet.dat when generating with walletupdate over json-rpc Post by: bernd83 on July 26, 2015, 02:37:20 PM 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. |