Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

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.

share|improve this question
add comment

4 Answers

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.

share|improve this answer
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.) –  Al E. Oct 19 '12 at 12:52
add comment
up vote 2 down vote accepted

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.)

  • sftp://android@192.168.99.199:2222/mnt/sdcard/

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

share|improve this answer
add comment

SSHDroid supports SFTP.

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

share|improve this answer
    
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 '12 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 '12 at 23:55
    
SSHDroid does not supports SFTP via USB. However, I found an app that does -- DigiSSHD. –  MountainX Jul 24 '12 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 '12 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. –  Richard Borcsik Jul 27 '12 at 7:19
show 1 more comment

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!

share|improve this answer
    
sounds interesting –  MountainX Feb 20 at 1:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.