Bitcoin Forum
May 14, 2024, 06:08:42 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Having trouble with wallet.dat when generating with walletupdate over json-rpc  (Read 1011 times)
bernd83 (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
July 21, 2015, 09:20:14 PM
 #1

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.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6641


Just writing some code


View Profile WWW
July 22, 2015, 01:29:46 AM
 #2

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.

bernd83 (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
July 22, 2015, 03:19:24 AM
 #3

@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?
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6641


Just writing some code


View Profile WWW
July 22, 2015, 03:47:50 AM
 #4

@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.

bernd83 (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
July 22, 2015, 03:57:18 AM
 #5

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.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6641


Just writing some code


View Profile WWW
July 22, 2015, 04:07:01 AM
 #6

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.

bernd83 (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
July 22, 2015, 04:21:44 AM
 #7

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?
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6641


Just writing some code


View Profile WWW
July 22, 2015, 05:54:35 AM
 #8

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.

bernd83 (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
July 26, 2015, 02:37:20 PM
 #9

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.

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!