Android APK: Copy directory via SSH

Eine App, die automatisch Daten an einen SSH Server schickt. Man hinterlegt die zu kopierenden Daten in ein Verzeichnis (z.B: Download) und startet die App. Die Übertragung startet automatisch; gleichnamige Zieldateien werden überschrieben. Das Zielverzeichnis ist vorgegeben.

 

Die Einstellungen stehen in Config.java:

static final String SOURCE = "/storage/emulated/0/Download";
static final String HOST = "dein-server.de";
static final int PORT = 22;
static final String USER = "dein-benutzer";
static final String DESTINATION = "/zielverzeichnis";

SSH-Schlüssel und geprüfte known_hosts einmalig übertragen — ersetze die lokalen Dateipfade:

adb shell run-as local.sshcopy mkdir -p files
adb shell run-as local.sshcopy sh -c '"cat > files/private_key"' < /pfad/zum/privaten_schluessel
adb shell run-as local.sshcopy sh -c '"cat > files/known_hosts"' < /pfad/zu/known_hosts
adb shell run-as local.sshcopy chmod 600 files/private_key files/known_hosts

Der Schlüssel muss ohne Passphrase sein. Öffne anschließend SSH Copy und erlaube den Dateizugriff.

Private/Public key

Auf dem Entwicklungr-PC erzeugen und auf das Smartphone übertragen

The key file is your SSH private key, used instead of a password to log into the server.

An SSH key pair has two files:

  • Private key, such as id_ed25519: stays secret. This app stores it under the filename z.

  • Public key, such as id_ed25519.pub: goes into the server user’s ~/.ssh/authorized_keys.

If you don’t have one, create a dedicated pair on your computer:

ssh-keygen -t ed25519 -f ~/.ssh/android_copy

Press Enter when asked for a passphrase—the current app requires an unencrypted key. Then authorize it on your server:

ssh-copy-id -i ~/.ssh/android_copy.pub your-user@your-server

The app’s key file is then ~/.ssh/android_copy, without .pub. Don’t paste its contents here.

App starten

Öffne auf deinem Smartphone die App „SSH Copy“. Erlaube beim ersten Start den Dateizugriff und kehre zur App zurück. Die Übertragung startet automatisch.

Alternativ vom verbundenen Computer:

adb shell am start -n local.sshcopy/.MainActivity

Falls sie noch nicht installiert ist:

adb install -r "/home/roland/Dokumente/ChatGPT/Android akp/SSHCopy.apk"

Für eine erfolgreiche Übertragung müssen Servereinstellungen, SSH-Schlüssel und known_hosts eingerichtet sein.

 

Build and upload

cd "/home/roland/Dokumente/ChatGPT/Android akp"
./build-apk.sh
adb install -r SSHCopy.apk