SFTP with DD-WRT

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 14:20, 22 January 2008 (edit)
Swift (Talk | contribs)

← Previous diff
Current revision (15:10, 6 December 2019) (edit) (undo)
Atatob (Talk | contribs)
m (Add languages menu)
 
(7 intermediate revisions not shown.)
Line 1: Line 1:
 +{{Languages|SFTP with DD-WRT}}
==Requirements== ==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. * 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.
Line 7: Line 8:
==Install the Packages== ==Install the Packages==
-# Install the [[Optware]] Dropbear package.+* Install the [[Optware]] Dropbear package.
ipkg-opt install dropbear ipkg-opt install dropbear
-# Install the [[Optware]] SFTP server package.+* Install the [[Optware]] SFTP server package.
ipkg-opt install openssh-sftp-server ipkg-opt install openssh-sftp-server
-# Configure /opt/etc/init.d/S51dropbear to set the Dropbear command line arguments you need.+* Configure /opt/etc/init.d/S51dropbear to set the Dropbear command line arguments you need.
 + '''Note: You can use the following command to find the default command line arguments'''
 + ps | grep dropbear
==Modify the Dropbear Executable== ==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.+* 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.+* 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 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.)+* 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= =Test It=
-# Start the Dropbear server.+* Start the Dropbear server.
/opt/etc/init.d/S51dropbear start /opt/etc/init.d/S51dropbear start
-# Attempt to connect with an SFTP client. It should work!+* Attempt to connect with an SFTP client. It should work!
-[[Category:English documentation]]+[[Category:Optware applications]]
[[Category:Advanced tutorials]] [[Category:Advanced tutorials]]

Current revision

Contents

[edit] 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

[edit] Install the Packages

  • Install the Optware Dropbear package.
ipkg-opt install dropbear
  • Install the Optware SFTP server package.
ipkg-opt install openssh-sftp-server
  • Configure /opt/etc/init.d/S51dropbear to set the Dropbear command line arguments you need.
Note: You can use the following command to find the default command line arguments
ps | grep dropbear

[edit] 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.)

[edit] 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).

[edit] Test It

  • Start the Dropbear server.
/opt/etc/init.d/S51dropbear start
  • Attempt to connect with an SFTP client. It should work!