Boot script to set ssh keyfile and disable clear password login

MyCloud Gen 2 (firmware 2.x)

The goal is to

  1. use ssh keyfile
  2. disable clear password login

After some research in this forum, I am planning to make following changes, not very familiar with WD OS, in order not to brick the NAS, can any experts advise if the changes will work or not? Thanks in advance!

Based on this post:

I will add following to /usr/local/config/config.xml

<name id="10">user_boot_script</name>


    <item id="1">
        <run>/shares/Public/backup/ &amp;</run>

User script:

#! /bin/sh


# only run once
if [ -f $LOCKFILE ]; then exit 0

# execute commands 5mins after reboot
sleep 5m

# copy backup .ssh/id_dsa to home folder
cp -r $BACKUP/.ssh $HOME/

# disable clear password login
sed -ir 's/(PasswordAuthentication yes)/PasswordAuthentication no/' $CONFIG

# restart sshd
kill -HUP `cat /var/run/`

My questions:

  1. Will above work? I just hope I don’t need to do 40s factory reset…
  2. Since the user cronjob runs every min, even it quits immediately because of the lock file, will it still wake up NAS from sleep?


Suggest that you do a check on your backed up .ssh folder. That way you dont nuke it on reboot.

i can verify the commands in the script one by one from command line, that’s not the problem.

my worry is, even the script works fine, i am not sure if it will run without issue when it is hooked on config.xml, which may cause MyCloud fails to boot?

I was meaning, you need to check for existence at destination before blindly copying the file. :stuck_out_tongue:

If not exist at destination:
  do copy
   If exist at destination
      rename destination
      do copy
   end if
end if 

That way you dont blast your backup.

I see. I think the root home folder is always wiped up after reboot.

Anyway thanks for the suggestion, it is good to check the existence.