3

First time poster and massive unix/linux novice here.

I have a Western Digital My Cloud NAS, which runs (I believe) some version of Debian. I've got a remote backup account with Rsync.net, and want to run daily backups using rsync from the NAS to the remote server.

I have full ssh access to the NAS. I've successfully generated the public and private keys using ssh-keygen -t rsa, and by default these are being placed in /home/root/.ssh/id_rsa. After which, I copy the public key to the remote server and can successfully ssh into the server from the NAS without a password. Testing with rsync works like a charm. A cronjob is then added to run a rsync bash script every day - so far so good.

However, on reboot the .ssh folder and all the keys are removed from the /home/root/ folder - I assume that entire folder gets wiped on reboot, as do folders like /root/ and others.

How do I prevent the /home/root/ folder from resetting every reboot?

Alternatively, I thought a good idea would be to use a new location for the ssh keys, and define the new folder using AuthorizedKeysFile in the sshd_config file. However, other than user shares (i.e, /shares/) I can't seem to find a directory that doesn't get wiped upon reboot.

Any ideas?

3
  • "I can't seem to find a directory that doesn't get wiped upon reboot." - then it's not a very useful nas :-> Oct 27, 2016 at 12:02
  • This question should be converted to one that inquires about persistent storage across reboots on this specific brand-and-model of NAS. It is misleading in its present form. The tags ssh, backup and rsync are also not the real domains of this problem -- they are probably nas, persistence etc.
    – nik
    Oct 27, 2016 at 15:41
  • @nik - thanks! Tags updated. Will update the question if needed as soon as I'm back at my desktop, but I think the "ssh keys" portion of my question is still valid - the solution may very well be that I need to change where my ssh keys are stored.
    – abza
    Oct 28, 2016 at 5:10

1 Answer 1

1

I think I have found a solution, which consists of the following steps.

  1. Since /home/root is reset each time after the reboot, we need to store id_rsa in a place, for example, in folder /shares/private, so that we can copy it to /home/root after each reboot.

  2. create a crontab job following the steps detailed in https://community.wd.com/t/additions-to-crontab-reverting/98317/52 . Please look at Grauwind's answer.

  3. Let the crontab job copy /shares/private/id_rsa to /home/root before your backup to your remote server. For example, if your backup to the remote server takes place at 6AM in the morning, set your crontab job to copy /shares/private/id_rsa to /home/root at 5AM would be sufficient.

Hope this helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .