1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Built a static SFTP server (plus a little bit about MMC)

Discussion in 'Tomato Firmware' started by pen_sq, Sep 28, 2008.

  1. pen_sq

    pen_sq LI Guru Member

    Well, it took me most of a day to figure out, I hope this helps somebody.

    I started this project off using Roadkill's mod. The hardware side is thanks to this guy. If you look at my pic, I just glued in a miniSD->microSD adapter (read a MiniSD pinout, it's a little jumbled!), and ground a little bit of the case. The wire is 30 gage "wire-wrapping" with Kynar. Right, on with the software!

    Some details are packaged less nicely than I'd like due to forum limits. The text files must lose their .txt filth, and the 2 zipped binaries should be tarballed together within a ssh-bin/ directory. Move them into ssh-bin, and fix permissions/root ownership (chmod o-rx ssh-bin ssh-bin/*) Bundle the binaries with "tar c ssh-bin | gzip -9 > ssh-bin.tgz". Yes, jffs compresses stuff for you, but not well enough.

    Edit passwdadd to put a real password in there, tomato doesn't have passwd to write one for you. Temporarily set the root password to what you want, and copy /etc/shadow 's cruft between the colons. Paste that into passwdadd, and change the root password back to something more comfortable.

    Transfer 3 files to the Linksys. You could do this with scp, wget from your own server, or cifs mount your PC. The script will extract the binaries to /tmp at bootup, where you'll sacrifice a little RAM.

    So, passwdadd, ssh-bin.tgz, and start-sftp.sh are all in /jffs. It's a little tight, but they should all fit in there. I have the following init script put in tomato's web interface.
    modprobe vfat
    modprobe mmc
    mkdir /mnt/card
    mount /dev/mmc/disc0/disc /mnt/card
    #argument - port number
    /jffs/start-sftp.sh 3000
    The most important part is the last line. 3000 is the port number for the EXTRA ssh (and sftp) server to live on. Yes, I needed to put another copy of dropbear(sshd) there just because of a hardcoded path to /usr/libexec/sftp-server. Root ssh logins are still at port 22

    The rest manually mounts my SD/MMC card. I think the kernel lacks support for DOS partition tables, which confuses Tomato. Instead, I made a naked partition on the disk. It works like mkfs.vfat -F 32 /dev/sdz, instead of mkfs.vfat -F 32 /dev/sdz1 ; though you better get that letter right. I have no idea how to do this part on Windows or OS-X, sorry.

    So far, I've used this on my local network (it's slow, at about 150K/s). That's about as fast as my cable's upload, so it should be good for trading files with a friend in the wrong time zone.

    Attached Files:

  2. pen_sq

    pen_sq LI Guru Member

    Behind the scenes!

    Here are the notes I took while building this Incredible Edifice. It shows the build options I used, and some of the workarounds for my lack of knowledge. It doesn't show half of the backspacing I did, or my simple-minded abuses of grep and vi.

    If anybody really, really cares, the build was done with Ubuntu 8, inside a VM on a Mac.

    Attached Files:

Share This Page