News for hackers. Stuff that matters.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by rl3 on Tuesday August 14, 2018 @11:11PM (#17763490)
I use an ad-free, open-source Android app called SimpleSSHD that implements a Dropbear SSH server. Being able to SSH into your phone and wirelessly perform an incremental rsync backup of all your photos and data is life-changing compared to the hell that is cables and the MTP protocol.

Thank you to all these projects for delivering me from the clutches of MTP, I am indebted.

Re:Dropbear SSH, a lightweight alternative to OpenSSH by adrianratnapala on Tuesday August 14, 2018 @11:24PM (#17763531)
A long time ago, when I tried something like that, I was stymied because the SSH server did not have permissions to write to any directory which the document readers etc. could see.

Is this sort of thing still a problem? How did you get around it?

Re:Dropbear SSH, a lightweight alternative to OpenSSH by tjoff on Wednesday August 15, 2018 @03:57AM (#17764380)
I haven't used SimpleSSHD but I use Termux, which gives me a "normal" terminal (no root required).

Since Android 8 I've lost write access to general locations in the sd-card but I still have read access, as well as read+write on the internal storage.

It has an ssh server which can be nice if you want to edit some files on the phone remotely but that's not needed for rsync. I have a shortcut on the home screen which triggers a script that runs an rsync command for photos and other stuff I want to backup. Also use it to reverse-sync a folder from my NAS, want to send a file to the phone? But the file in that folder and run the script.

Re:Dropbear SSH, a lightweight alternative to OpenSSH by pozibrothers on Wednesday August 15, 2018 @04:07AM (#17764420)
I think that you need to run the command "termux-setup-storage" to be able to r/w again:

https://wiki.termux.com/wiki/Termux-setup-storage

Re:Dropbear SSH, a lightweight alternative to OpenSSH by tjoff on Wednesday August 15, 2018 @05:10AM (#17764641)
Thanks, doesn't work though. I have write access to the private directory for termux on the sdcard but nothing else (which unfortunately breaks my usage, I'll report it to them any day to see if a fix is possible).
Re:Dropbear SSH, a lightweight alternative to OpenSSH by sedlav on Wednesday August 15, 2018 @01:09PM (#17767724)
This is the way Termux works so far, External storage: Storage on external SD cards. Each app has a private folder on the external SD card, and interchange between them needs to use a special API not yet available in Termux.

https://wiki.termux.com/wiki/Internal_and_external_storage

Re:Dropbear SSH, a lightweight alternative to OpenSSH by tjoff on Wednesday August 15, 2018 @02:15PM (#17768356)
It worked fine in Android 7, when I updated to 8 my scripts started getting permission-denied errors on writes.

I don't see anything in that link that says that sdcard (outside private folder) is read-only.

The way I read "Each app has a private folder on the external SD card, and interchange between them needs to use a special API not yet available in Termux." is that I can't read another applications private folder, but I'm not trying to - I just want (write+delete) access to the publicly accessible parts of the sdcard (lots of other applications do this, and termux did in Android 7).

Re:Dropbear SSH, a lightweight alternative to OpenSSH by sedlav on Tuesday August 21, 2018 @07:35PM (#17814852)
Well I have Android 7 and termux works in the way you described at first: I have write access to the private directory for termux on the sdcard but nothing else... other applications can access every DIR in sdclard due implements SAF: https://developer.android.com/guide/topics/providers/documen... and I think this what termux doc refers to.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by rl3 on Tuesday August 14, 2018 @11:26PM (#17763538)
It was never an issue for me. Giving the SimpleSSHD docs a quick glance, the app itself does not operate as root, although its packaged subcomponents like rsync optionally can depending on what shell you point them to.

My phone isn't rooted. Everything in /storage/emulated/0 backs up without issue. Obviously not a full system backup, but all my data none the less.

With regards to write permission, I've only ever issued any writes to my image folders to prune photos or screenshots older than xx days that have already been backed up. On that note, freeing up 20GB of space instantly with a single command is incredibly satisfying (compared to the MTP hell alternative).

Re:Dropbear SSH, a lightweight alternative to OpenSSH by CapacitorSet on Tuesday August 14, 2018 @11:44PM (#17763603)
If you only need a shell, adb does that, as well as blazing fast file transfer (for the standards of MTP).
Re:Dropbear SSH, a lightweight alternative to OpenSSH by rl3 on Wednesday August 15, 2018 @12:27AM (#17763768)
For sure, although I think it isn't as well suited to being a remote daemon. With SimpleSSHD, all concerns are compartmentalized into an app, you get rsync out of the box plus a nice minimalist UI for monitoring. Then adb can be left disabled, and its configuration untouched.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by CyberShadow on Wednesday August 15, 2018 @03:15AM (#17764248)
If your phone is rooted, you can use e.g. Linux Deploy to install a full Linux distribution. Then, you can set up regular ol' OpenSSH, mount /sys and /data under the Linux chroot, and rsync as usual.

I use this method to rsync to btrfs snapshots (+ raw copies of non-filesystem partitions) to make daily incremental backups of the entire phone. (Restoring said backups is a bit more involved, but I verified it's doable.)

Re:Dropbear SSH, a lightweight alternative to OpenSSH by paulie_a on Wednesday August 15, 2018 @07:06AM (#17765153)
I'd backup to a more reliable filesystem than btrfs. In my experience you will eventually randomly lose data with btrfs. I have lost all trust in it.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by CyberShadow on Saturday August 25, 2018 @03:54PM (#17842303)
Backups are by definition redundant, however, btrfs is still the only Linux filesystem with its featureset. Let me know when ZFS on Linux supports shrinking or cloning file ranges.

https://news.ycombinator.com/item?id=16494370

Re:Dropbear SSH, a lightweight alternative to OpenSSH by dokument on Wednesday August 15, 2018 @12:15PM (#17767194)
"raid" 1/0 and 10 are stable, others are not. Theoretically btrfs can protect against bit-rot where other fs's typically don't.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by paulie_a on Wednesday August 15, 2018 @01:18PM (#17767805)
Theoretically that might be the goal. In my experience data melts away like butter on btrfs.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by trumped on Wednesday August 15, 2018 @12:14PM (#17767179)
This is an Android problem that is sold as a feature by Google... still a problem on my version of Android (in Android 5.0 and later, an app can request the permission for reading/writing to a folder on the SD card though: https://metactrl.com/docs/sdcard-on-lollipop/ )
Re:Dropbear SSH, a lightweight alternative to OpenSSH by ajbqq on Wednesday August 15, 2018 @03:40AM (#17764320)
I use the Syncopoli app which can do this on a scheduled basis. It uses Dropbear internally and is also on F-Droid. You do need a SSH server but you can limit the wireless networks it syncs on, so it needn't be public.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by _hyn3 on Wednesday August 15, 2018 @11:13AM (#17766633)
Syncthing does an admirable job here as well (also available on F-droid).
Re:Dropbear SSH, a lightweight alternative to OpenSSH by genpfault on Wednesday August 15, 2018 @02:59PM (#17768729)
Does syncthing work on SD cards yet?

Last I checked there were some Go/Android technical hurdles that prevented it from working.

Re:Dropbear SSH, a lightweight alternative to OpenSSH by namanyayg on Wednesday August 15, 2018 @03:24AM (#17764274)
Great idea, I'd grown too reliant on Google Photos and always hated that. I should set this up.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by tambourine_man on Wednesday August 15, 2018 @01:23AM (#17763930)
Is there an equivalent for iOS?
Re:Dropbear SSH, a lightweight alternative to OpenSSH by honkycat on Wednesday August 15, 2018 @01:42AM (#17763978)
Lol
Re:Dropbear SSH, a lightweight alternative to OpenSSH by Terretta on Wednesday August 15, 2018 @06:00AM (#17764831)
Let’s keep in mind the user story: “Being able to wirelessly perform an incremental backup of all your photos and data is life-changing”

The LOL is telling your Mom about DropbearSSH when this is now how iCloud Photos and Files just works. The equivalent goal is baked in.

You can still use cables or local WiFi via iTunes, but now all media and files sync over-the-air as files, along with an incremental backup of all state.

For the first time in last fall’s iPhone hardware upgrade, I didn’t use a wired backup/restore and every app’s and settings worked, along with device config. I’ve had an iPad Pro unexpectedly need replacing, no wired backup/restore needed. All my stuff syncs across all devices including desktop, all ambiently available.

The life changing part is confidence it’s working to the point of not having to think about it any more.

// Note: Photos and media end up as originals on Mac, along with all files. Those all backup in turn to Backblaze, for loss scenarios not covered by rsync style replication.

Re:Dropbear SSH, a lightweight alternative to OpenSSH by _hyn3 on Wednesday August 15, 2018 @11:08AM (#17766586)
Everything in iCloud, including your encrypted messages, are easily accessible to Apple[0] and will be released without a fight, despite Apple's vaunted privacy stance. (Perhaps that social contract has some fine print if the CEO of your company looks at your files and decides you're guilty without wasting time with 'a jury of your peers' and all that nonsense.)

Android (with Google) offers the same functionality (AFAIK) as iCloud, but sometimes you just prefer that your private photos remain just that.

0. https://news.vice.com/en_us/article/xwm4ya/paul-manafort-may...

Re:Dropbear SSH, a lightweight alternative to OpenSSH by greedo on Wednesday August 15, 2018 @03:00PM (#17768735)
Any data you sync to a cloud provider is subject to subpoena by LEO.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by grawlinson on Thursday August 16, 2018 @04:15AM (#17772857)
tarsnap/cryptfs should really be SOP when uploading anything to cloud.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by brazzledazzle on Wednesday August 15, 2018 @02:23AM (#17764099)
Despite how inappropriate this comment is its cynicism is appreciated. I like my iPhone but I miss Android for things like this.

That said, I think it might be possible but I think you might have to shim it and wouldn’t have direct access to the file system under the photos.

Re:Dropbear SSH, a lightweight alternative to OpenSSH by tambourine_man on Wednesday August 15, 2018 @08:04AM (#17765367)
Thank you for your thoughtful contribution.

Open Terminal managed to sandbox a busybox like suite (grep, curl, gzip…). And a scripting language to boot.

rsync limited to the app's directory + shared folders such Photos, iCloud drive, etc would be pretty useful, even without full file system access.

iOS's restrictions are loosening up, vide Files.app

Re:Dropbear SSH, a lightweight alternative to OpenSSH by have_faith on Wednesday August 15, 2018 @05:06AM (#17764629)
As an iOS user this is an appropriate response.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by perch56 on Wednesday August 15, 2018 @02:16AM (#17764079)
iLol :)
Re:Dropbear SSH, a lightweight alternative to OpenSSH by sjmulder on Wednesday August 15, 2018 @03:18AM (#17764254)
For non-jailbroken devices that wouldn't be possible in the same way, but an app could certainly implement SSH with libraries (photos, contacts, etc) exposed as a filesystem and interpret a set of commands (like rsync).
Re:Dropbear SSH, a lightweight alternative to OpenSSH by avar on Wednesday August 15, 2018 @05:06AM (#17764624)
It's somewhat flaky, but you can also mount your phone as a local FS over USB debugging, requires a wired connection though: https://github.com/spion/adbfs-rootless
Re:Dropbear SSH, a lightweight alternative to OpenSSH by jeroenhd on Wednesday August 15, 2018 @05:58AM (#17764826)
It's possible on most devices to use adb over the network. It's a separate toggle in the de developer settings as it exposes the adb port to all network interfaces (think WiFi, LTE, Bluetooth, etc.) Use `adb connect <ip>` to connect to your device over WiFi and you should be able to use this tool without having a wired connection to the phone.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by LudoA on Wednesday August 15, 2018 @06:07AM (#17764852)
What do you use to have rsync on your phone?

And did you have to root your phone to achieve any of this?

Also, is there a tool to use duckdns or similar to assign a hostname to your phone?

Re:Dropbear SSH, a lightweight alternative to OpenSSH by rl3 on Wednesday August 15, 2018 @07:37AM (#17765260)
1) SimpleSSHD includes rsync.

2) No.

3) Haven't looked into dynamic DNS yet; only using the setup with local wifi currently.

Re:Dropbear SSH, a lightweight alternative to OpenSSH by agumonkey on Wednesday August 15, 2018 @06:17AM (#17764903)
I use acrosync, a rsync UI, pretty limited but works... I'm gonna try your sshd to see if it's better.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by xg15 on Wednesday August 15, 2018 @04:01AM (#17764393)
With Android now restricting background services, will this continue to work in the future?
Re:Dropbear SSH, a lightweight alternative to OpenSSH by guipsp on Wednesday August 15, 2018 @05:31AM (#17764735)
Short answer: yes
Re:Dropbear SSH, a lightweight alternative to OpenSSH by holmberd on Wednesday August 15, 2018 @12:07AM (#17763694)
Love it, works like a charm.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by andreareina on Wednesday August 15, 2018 @12:53AM (#17763852)
Since the phone's IP address can be expected to change, you can't really use that to choose the right key to present, or to verify the host fingerprint right?. How do you work around this?
Re:Dropbear SSH, a lightweight alternative to OpenSSH by maaarghk on Wednesday August 15, 2018 @01:02AM (#17763875)
You can set a static IP in your wireless settings.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by spockz on Wednesday August 15, 2018 @01:42AM (#17763980)
Or ‘better’ fix an IP to your device MAC in your dhcp settings.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by gonvaled on Wednesday August 15, 2018 @02:30AM (#17764116)
Usually not needed, since your router will usually try to assign a fixed address for already known devices.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by JdeBP on Wednesday August 15, 2018 @08:12AM (#17765405)
What spockz said takes the words "usually" and "try" out of that. (-:
Re:Dropbear SSH, a lightweight alternative to OpenSSH by gonvaled on Thursday August 16, 2018 @11:20AM (#17775384)
But means more work, with web interfaces of varying quality
Re:Dropbear SSH, a lightweight alternative to OpenSSH by voltagex_ on Wednesday August 15, 2018 @10:14PM (#17771365)
What happens when the DHCP lease expires?
Re:Dropbear SSH, a lightweight alternative to OpenSSH by gonvaled on Thursday August 16, 2018 @10:51AM (#17775087)
The router will try to reassign it, usually.
Re:Dropbear SSH, a lightweight alternative to OpenSSH by andreareina on Wednesday August 15, 2018 @05:57AM (#17764821)
Not all routers support this. In fact at work we've got a router that seems to black-hole anything whose source or destination isn't in the DHCP table (TP-Link 480t+).

In the end I solved this by accessing this only while I'm tethered, that fixes the phone's IP address.

Too bad there doesn't seem to be an option to select keys according to host key instead of hostname or alias.