chrooted debian on Zyxel NSA310
I have roughly documented my procedure below; the two scripts you will need are in a git repository. When you follow these steps, you will end up with a fully functional Debian chroot in which you can use apt-get to install additional software. We will also setup telnet running outside of the chroot, accessible from localhost, for easy root access to the NSA itself without going through the backdoor sequence every time.
Of course, this is just a guide, written according to my taste and preferences. Feel free to do things your way; I’d love a comment to hear what you did differently.
One final note: this setup only arranges for ssh and localhost telnet to be started on boot; other daemons you install inside Debian will not get automatic startups. I believe you can replace the ssh line in init.sh with something else to get a full Debian startup, but for now I have no need for it.
- grab a working Debian box (I used Debian 6/squeeze amd64), and run ‘
sudo /usr/sbin/debootstrap --foreign --arch=armel --variant=minbase --include=openssh-server squeeze ./nas-debootstrap/ ftp://ftp.nl.debian.org/debian’. This creates a Debian environment in./nas-debootstrap/. Tar it up and copy it to the NSA (in any share will do). - open telnet on the NSA310 - log in as administrator on the webinterface and browse to ‘
/zyxel/cgi-bin/remote_help-cgi?type=backdoor’. This opens telnet (port 23). The URL never finishes loading for me, but you can just cancel it. Username is root; password is your admin password. - on my box, the main storage dir is
/i-data/370f61a5which seems a bad thing to standardise on;/etc/zyxel/storage/sysvolis a symlink to it, and we’ll use that from here on. - in
/etc/zyxel/storage/sysvolI made a dir.debian; I will refer to this dir as.debianfrom now on. - extract the tarball and rename it to
.debian/root. - type ‘
chroot .debian/root /debootstrap/debootstrap --second-stage’ to finish the debootstrap. Then, set a root password: ‘chroot .debian/root passwd root’. Note: after this step you can enter your Debian setup by saying ‘chroot .debian/root’ to look around a bit - ‘
mkdir .debian/root/data’ for mounting our actual storage. - outside of the chroot, grab
init.shandtelnet.shfrom the git repo and put them in.debianand chmod +x them. Putchroot-initin.debian/root/etcand chmod +x it too. - ‘
cd /usr/local/zy-pkgs/etc/init.d; ln -s /etc/zyxel/storage/sysvol/.debian/init.sh DEBIAN; ln -s /etc/zyxel/storage/sysvol/.debian/telnet.sh LOTELNET’
Now, you should have a Debian setup that starts when you boot your NAS. If everything looks okay, type ‘reboot’ to give it a shot! A reboot on mine (with or without Debian) takes about two minutes, so don’t panic!
When it is up again, try ‘ssh root@nsa310’ replacing nsa310 with the IP or perhaps internal hostname you have. This should drop you into a bash shell inside your Debian setup!
One last thing: to use apt-get, you’ll need a sources.list configuration for it. I recommend using Debian Sources List Generator for this.
Hi,
thank you for your post.
I have successfully chrooted my NSA320.
this is the most comprehensive howto that i have found.
Comment by Alessandro — Apr 29, 2012 6:56:17 PM | # - re
and what is the way back to the boot into the standard os of this nas?
Comment by anony — May 8, 2012 3:15:43 PM | # - re
Hello anony,
this howto does not replace the standard OS of the NAS; it starts a Debian SSHD in addition to your stock OS. If you want to stop that from happening, remove the symlinks you added to /usr/local/zy-pkgs/etc/init.d
Comment by peter — May 30, 2012 8:53:10 AM | # - re
What firmware on the nsa310 is this supported?
Comment by M3cab — Jun 8, 2012 9:28:44 AM | # - re
Hello M3cab,
I believe it requires 4.40 or up (and will not work with 4.30 or lower); I’m using 4.40 and I’ve heard it works on 4.50 too.
Comment by peter — Jun 19, 2012 1:05:57 PM | # - re