Why no persistent changes to root home folder?


Recommended Posts

I have another server setup that I would like to do some daily backups of. It supports backing up via SSH. So I went through and setup the /root/.ssh/known_hosts file with the public key from the other server and it was all working great. But then I rebooted unraid and to my surprise the setup was completely gone and my backups started failing.

 

So is there a way to make this change persist through reboots?

Link to comment

Unraid runs from RAM which is why it did not survive a reboot.

 

If you want any file to survive a reboot then you need to store a copy on the flash drive and copy it into its runtime position using either entries in the config/go file or using the User Scripts plugin.

Link to comment
5 hours ago, itimpi said:

Unraid runs from RAM which is why it did not survive a reboot.

 

If you want any file to survive a reboot then you need to store a copy on the flash drive and copy it into its runtime position using either entries in the config/go file or using the User Scripts plugin.

 

Thanks! I installed the plugin, and created the script. I assume that I can put the authorized_keys file in the same place as the script and it won't be deleted or lost at a reboot?

Also, how do I schedule this to run at boot? The only cron options seem to have to do with the array startup and spin-down.

 

Link to comment
2 hours ago, lutiana said:

 

Thanks! I installed the plugin, and created the script. I assume that I can put the authorized_keys file in the same place as the script and it won't be deleted or lost at a reboot?

Also, how do I schedule this to run at boot? The only cron options seem to have to do with the array startup and spin-down.

 

You cannot (currently at least) schedule items via the User Scripts plugin to run at boot (although it has been hinted some additional scheduling options might be added).   If you want it run as part of the boot process then add the commands to the config/go file on the usb drive.

Link to comment
9 hours ago, lutiana said:

Thanks! I installed the plugin, and created the script. I assume that I can put the authorized_keys file in the same place as the script and it won't be deleted or lost at a reboot?

I am doing backups from one server to another via rsync/ssh.  I use a combination of go file entries to keep things persistent through reboots and User Scripts to run the backup on a scheduled basis.

 

Here is an example of my go file entries in the source server to copy what is needed to access the backup server.  There are similar entries in the go file of the backup server referencing the source server.

# Copy SSH files back to /root/.ssh folder and set permissions for files
mkdir -p /root/.ssh
cp /boot/config/ssh/medianas_key /root/.ssh/id_rsa
cp /boot/config/ssh/known_hosts /root/.ssh/known_hosts
cat /boot/config/ssh/backupnas_key.pub > /root/.ssh/authorized_keys
chmod g-rwx,o-rwx -R /root/.ssh

Been running the script for over two years without issue and through many, many reboots of both servers.

Link to comment
10 minutes ago, lutiana said:

Well I mean, I figured that, but what is the exact path that is in? Or does that vary from install to install?

Depends where you access it from. \\tower\flash\config\go over SMB, /boot/config/go over SSH or at the console, X:\config\go where X is the mounted drive letter if you put the USB stick in your windows box.

Link to comment
3 minutes ago, jonathanm said:

Depends where you access it from. \\tower\flash\config\go over SMB, /boot/config/go over SSH or at the console, X:\config\go where X is the mounted drive letter if you put the USB stick in your windows box.

Perfect, thanks!

Link to comment
  • 4 weeks later...
On 6/10/2020 at 7:18 PM, Hoopster said:

I am doing backups from one server to another via rsync/ssh.  I use a combination of go file entries to keep things persistent through reboots and User Scripts to run the backup on a scheduled basis.

 

Here is an example of my go file entries in the source server to copy what is needed to access the backup server.  There are similar entries in the go file of the backup server referencing the source server.


# Copy SSH files back to /root/.ssh folder and set permissions for files
mkdir -p /root/.ssh
cp /boot/config/ssh/medianas_key /root/.ssh/id_rsa
cp /boot/config/ssh/known_hosts /root/.ssh/known_hosts
cat /boot/config/ssh/backupnas_key.pub > /root/.ssh/authorized_keys
chmod g-rwx,o-rwx -R /root/.ssh

Been running the script for over two years without issue and through many, many reboots of both servers.

 

I want to make a little change that will make files in /root/.ssh persistent but will affect your script.

 

That is simply this: create /root/.ssh which is a symlink to /boot/config/ssh/root

 

/boot/config/ssh/root is a directory where you put authorized_keys, known_hosts, etc.

 

Sound good?

 

  • Like 3
  • Thanks 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.