On our NAS running Debian Lenny I stupidly set PermitRootLogin to without-password in sshd_config without properly setting up the keys first and am now locked out. It's a WD Sharespace and reading up on it it looks like my best way to restore root SSH access is to create a deb package that overwrites the original sshd_config file. The sites I've found describing deb package creation are pretty onerous. All I need the package to do is overwrite a single file. Is there a simple way to do this?
There are some tools that make it easier to do some simple packaging, but packaging is a fundamentally complex task since packages can do so many things (write out binaries, configuration files, run postinstall scripts, etc.)
That said, if all you need to do is package a file to appear at a specific location, one such tool is fpm (needs Ruby). Not to disrespect fpm, it can do much more than just package a dir full of stuff!
Create the directory structure you want to have packaged somewhere, here in /tmp
. Act as if /tmp/mypackage
is the root of your target filesystem, so anything you place in mypackage/etc
will show up in /etc
after installing the package:
mkdir -p /tmp/mypackage/etc
echo "My file contents" > /tmp/mypackage/etc/my_config_file
Stick your sshd_config
file in that etc
directory. Then we package that up:
fpm -t "deb" -n "mypackage" -s dir /tmp/mypackage
You should get something like:
Created package {:path=>"mypackage_1.0_amd64.deb"}
Make sure to set the right architecture (I don't know what the WD Sharespace uses) with the -a
option. Once you install that package on your NAS, the config file should show up there.