3

I want to run an SFTP server on my GSM Galaxy Nexus (Cyanogenmod 9 RC2). I plan to connect to the Galaxy Nexus from a Kubuntu 12.04 PC via USB cable (not wireless).

It is my understanding that Dropbear does not include SFTP at this time. What are my other options? If anyone knows how to do this, I would appreciate a tutorial or a link to a tutorial. Thanks.

4 Answers 4

3

I realize this question is a bit old and therefore the original poster may no longer benefit from this answer, but I'ma try anyhow, just in case anyone else has this exact same question. I have this working flawlessly (as far as I can tell) on devices running versions of android ranging from 2.2 up to 4.3, all using DropBear, however it took a bit of searching to find the solution. What the problem is, put simply, DropBear (as included in most Android app markets) does not apparently include the binary for sftp-server for some unfathomable reason. The (somewhat) simple fix was found in the discussion thread for Issue #1 at the droidsshd Google Code project. I will now explain that solution step by step for future visitors to this question.

  1. Install droidsshd or dropbear app from your favorite Android market app.
  2. Configure appropriately so that it is working fine for normal ssh connections.
  3. Try sftp root@<your droid ip address> to confirm it as non-working and to get an error message telling you where it is expecting to find the sftp-server binary at.
  4. Download the sftp-server binary found in comment #6 of the aforementioned Issue #1 discussion.
  5. Use whatever available means necessary to get that sftp-server binary into your device's sdcard. (I prefer AirDroid personally, but your favorite method will work equally well I'm sure.)
  6. ssh into your droid device and copy that binary into the appropriate folder from the error message above in step 3. (You may need to create a folder or two if they don't exist yet. I did.)

    • ssh root@<your droid ip address>
    • mkdir -p <path to expected folder>
    • cp /mnt/sdcard/sftp-server <path to expected folder>
    • If the previous command failed, try "mount -o remount,rw /" to mount the appropriate partition as read/write then try the previous copy command again.
    • rm /mnt/sdcard/sftp-server

By this time you should be in a position to restart the DropBear server and then enter an sftp://root@droid/ style address in Dolphin (or whatever similar method in your file manager of choice). This method has worked for me (on four different devices thus far). I hope it helps you, too.

1
  • 1
    This is the kind of answer we like around here. As for those links you couldn't add, you can either add them with backticks (``) so that they don't render as live links or leave them here in the comments so someone with enough reputation points can edit them in. Or, just wait a little bit for your reputation to increase so you can do it yourself. (But don't leave commentary about site limitations in your posts.)
    – ale
    Oct 19, 2012 at 12:52
2

The reason for using SFTP over USB is speed and convenience. MTP is unsatifactory, and transfering files over WiFi is slow.

For those of you who have my setup (GSM Galaxy Nexus with Cyanogenmod 9 RC2 or later) here's how to manage files on your device with maximum convenience and speed.

  • Install DigiSSHd (and DigiControl) on phone
  • connect phone to PC via USB cable

  • On phone, go to Settings > Wireless & Networks > More... > Tethering and portable hotspot > check "Enable USB tethering" Done. Exit settings.

The first time setting up DigiSSHd on phone, open DigiSSHd and enable it (so it becomes active).

Since I'm running KDE, I use Dolphin. Here's how to manage files on my phone with Dolphin. (You could do the same with Nautilus, but the syntax may be different.)

This assumes the default port of 2222. You can change password, port, etc. in DIgiSSHd settings.

Once it is set up, establishing the connection is super easy. And managing files via a real file manager is way superior to using MTP.

See more here: http://forum.xda-developers.com/showpost.php?p=29267792&postcount=12

2

I had the same problem for too long now and stumbled upon this question.

Since this is a USB operation, using encryption (SSH) provides no useful security, but will tax the two CPUs, drain the phone battery and might reduce transfer speed.

I am therefore very happy to say that I am transferring a 4GB file at 9.2MB/s from my phone to my Ubuntu machine using USB tethering and primitive ftpd. Primitive ftpd is a plain FTP server, so it doesn't have this encription/decryption overhead and is also FOSS (available through F-Droid), so it does not require me to have a Google account and sacrifice privacy for access to apps.

Perfect!

1
  • sounds interesting
    – MountainX
    Feb 20, 2014 at 1:13
1

SSHDroid supports SFTP.

I'm not sure there is any point of doing SFTP through a USB cable though, who are you securing against?

6
  • Doing this via USB would require USB tethering which has to enabled after every USB plug in. Seems overly complex in comparison to normal networking, i.e. both devices connected through a common router/AP ... Using adb (the android debug bridge) is also quick and fast.. but very unsafe however.
    – ce4
    Jul 24, 2012 at 20:21
  • It has nothing to do with security. My objective is to manage and transfer files via Dolphin. I am simply looking for convenience. MTP (especially gMTP) sucks. the Android adb bridge is OK, but not as good as SFTP with Dolphin.
    – MountainX
    Jul 24, 2012 at 23:55
  • SSHDroid does not supports SFTP via USB. However, I found an app that does -- DigiSSHD.
    – MountainX
    Jul 24, 2012 at 23:56
  • The reason for using a USB cable rather than WiFi is speed (as well as a more reliable connection).
    – MountainX
    Jul 25, 2012 at 0:00
  • @MountainX I'm pretty sure that for most phones WiFi is not the bottleneck. My phone doesn't have N support so I'm limited to 54Mb/s but most new phones aren't. This way I get about 5MB/s. With USB transfer 12MB/s.
    – user13391
    Jul 27, 2012 at 7:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .