TechInfoDepot:DD-WRT/SFTP with DD-WRT

Requirements

 * Although it wouldn't be too hard to make a firmware image that supports SFTP, you'll need a router with enough space to install Optware until someone does that.
 * You'll need access to Perl, either using the Optware package on your router or on another machine, to follow this tutorial exactly. You can substitute another utility that can edit binary files if you prefer.
 * It's smart to disable the built-in Dropbear daemon before you begin this tutorial and do this via telnet. Otherwise, when you attempt to disable the built-in version later, it will kill all Dropbear processes including your new one and you'll have to manually restart the new version by running the following command in the web interface.

/opt/etc/init.d/S51dropbear start

Install the Packages

 * Install the Optware Dropbear package.

ipkg-opt install dropbear


 * Install the Optware SFTP server package.

ipkg-opt install openssh-sftp-server

Note: You can use the following command to find the default command line arguments ps | grep dropbear
 * Configure /opt/etc/init.d/S51dropbear to set the Dropbear command line arguments you need.

Modify the Dropbear Executable

 * If you don't have Perl installed on your router, copy /opt/sbin/dropbear to a machine that does have it. Regardless, make sure that you work with a copy in case something goes wrong.
 * Modify the executable to use /opt/libexec/sftp-server instead of /usr/libexec/sftp-server.

perl -pi -e 's/\/usr\/libexec\/sftp-server/\/opt\/libexec\/sftp-server/g' dropbear


 * Copy the modified Dropbear executable into /opt/sbin. (You can overwrite the existing /opt/sbin/dropbear since it's just a symbolic link to /opt/sbin/dropbearmulti.)

Alternate way, using built-in sed command instead of Perl
sed 's/\/usr\/libexe/\/opt\/libexe/g' dropbearmulti > dropbear.modified

(This is a huge hack, all due to the fact that we can't get to /usr/libexec/sftp-server directly. Otherwise we could just install the OpenSSH sftp-server and be done with it).

=Test It=
 * Start the Dropbear server.

/opt/etc/init.d/S51dropbear start


 * Attempt to connect with an SFTP client. It should work!