Accidentally cut-off SSH root access

I’ve been experimenting setting up our WD Share Space as an rysnc server. Had it working great, then editted /etc/sshd_config and set PermitRootLogin to without-password without properly setting up my SSH keys. Now I can’t SSH into our WDSS as root. I can SSH as a regular user, but then don’t have user permissions to edit the sshd_config file. I can login as root through the web interface, but am not seeing where I could use it to modify the file. Any way I can reset or edit the sshd_config file back to what it was?

Does this help any?

[GUIDE] SSH Lockout Fix for people messing with sshd_config

Boujii, Thanks for the suggestion. It looks like what I need but is a bit over my head. The first post lists a file what is out of date according to the thread (I tried to install, but got an “unrecognized character” error.) Toward the bottom someone posted three scripts (control (MBL Duo, preinst, postinst) but it’s not clear to me how to install them using a firmware update.

Your suggestion took me down a path where people were doing a factory reset to regain access to their devices. I have no data or settings on mine that I care about, so last night I did a Configuration > Factory Default Restore. Then did a device reset (via paper clip). This wiped clean a lot of stuff, but I still cannot login as root. I can SSH as admin and when I view /etc/sshd_config I see that my setting for PermitRootLogin is still set to without-password, so I’m still stuck.

Is the creating my own firmware update still the way to go? Alternatively, can I do a fresh install of the OS to start with a clean slate? I’m not sure how to proceed with either of these options, so any advice would be much appreciated.

Update: Reading other threads about people locked out of there Sharespace’s, an option is to reinstall the firmware by doing a manual reinstall. I tried that, but am getting an error “The firmware image is not valid”. Some searching found that this error can be triggered when there’s not enough space on md0 to accept the update. 50% free space appears to be required and Thonky appears to be installed on md0 which may be the problem. I’m not strong in Linux and inherited the Sharespace from a predicessor, so didn’t set it up and am not clear on how to check for disc space and move Thonky. (I’m setting up the SS as an rsync server, so don’t need iTunes, Thonky, etc., and would prefer to uninstall them if possible). Is it possible to do this without root access? If so, what are the steps?

Update: Boujii, I took a closer look at the thread you recommend and used 7-zip to deconstruct the original solution that linked to a .deb file. As you know, it contains a sshd_config file that overwrites the broken one. The .deb file is for a My Book I think and isn’t compatible with my Sharespace, but it looks pretty straight forward to build my own .deb file that has my repaired sshd_config file. A couple questions. First, what path should I put to my sshd_config file in the .deb file? The posted My Book solution inside path is


The path on my Sharespace to the sshd_config file is /etc/sshd_config, so no “ssh” directory and its not in “DataVolume”. Also, the path in the updateFile.deb file includes a “.” directory, which Windows won’t let me create. Second, I’m not familiar with “.deb” format - is it just “.zip” file with the extension renamed?

Sorry for being all over the place with attempts.

That stuff is way beyond me lol. I mean I got the jist of what you was saying but sound like this might need a linux person :frowning:

Which I really am not all that familiar with.

Nevertheless, keep the thread going because there are a lot of linux guru’s out there :slight_smile:

I’m invesigating creating my own .deb package to restore my sshd_config file and it looks like a fairly major undertaking. Is there no way to “reset” the sshd_config file? I’m a bit disappointed the WD “restore to factory settings” didn’t do the job.

Update: Got some nice instruction for creating custom .deb file on StackExchange:

Seem to work great and I now have a custom .deb file. Unfortunately I can’t install because my /dev/md0 is at 70% full. Apparently, it has to be at 50% or less or you get  a generic error “The filename of the firmware image contains invalid characters.”

Is there a way to get /dev/md0 below 50% without root SSH access?