Skip to content

Instantly share code, notes, and snippets.

@jaimemrjm
Last active September 20, 2025 21:39
Show Gist options
  • Save jaimemrjm/941dfc7050ca89ae85f4acb106879fd3 to your computer and use it in GitHub Desktop.
Save jaimemrjm/941dfc7050ca89ae85f4acb106879fd3 to your computer and use it in GitHub Desktop.
Android phone tips: SSH / FTP server (for backup, sync...), Samsung Dex

Restore apps when new Android phone

  1. Install termux, rsync and copy your SSH key and restore your files with rsync (see next section).
  2. Copy your keepassx database via adb, Telegram or Google Drive.
  3. Open the keepassx database, config your Nextcloud app.
  4. Config keepassx2Android to use Nextcloud app.
  5. Install the latest TaskerSettings by using adb
  6. Set manually Android system permissions for Tasker by using adb and enable "Modify system settings" in the Android settings for Tasker.
  7. Enjoy your Android phone.

SSH Server in Android

Termux in a powerful app to run a Linux environment, making possible your Android phone has some applications or tools like a desktop computer. So you could backup your phone content seamlessly without any propietary cloud. You can use the embedded ssh server running at 8022 port.

Allow storage permissions and install ssh server is easy in Termux: pkg install openssh.

Config your SSH config in your computer

Edit your ~/.ssh/config to config the Android phone IP address. For example, I use the alias myphone and my router assigns the 192.168.1.4 IP-address:

host myphone
    Hostname 192.168.1.4
    Port 8022

Config your Android phone

Then in your Android phone, open Termux and execute whoami. Get the user name, and set the password with the command passwd.

(Optionally) Install rsync: pkg install rsync

Then copy your public key from your computer: ssh-copy-id -i ~/.ssh/id_rsa.pub <your_phone_ip>

Backup/Sync your phone files to your computer

  • Start the SSH server in background from Termux: sshd or sshd -D if you want to stop in any case.
  • Get the Android IP network adderss: ip a
  • Rsync from your computer:
rsync -avz --no-perms --no-times --exclude=thumbnails --exclude=.thumbnails --exclude=tmfs --exclude=.tmfs --exclude=trash --exclude=.Trash --delete-excluded galaxys24:~/storage/shared/  <your_phone_ip>:/~/storage/shared <backup_path_in_your_computer>

Disable password authentication (optionally)

To improve security, go to $PREFIX/etc/ssh/ in your phone and modify the sshd_config file (for example, use nano sshd_config) and switch the config line PasswordAuthentication from yes to no.

Alternative connection via USB

If you have no WiFi available (for example, by train/underground/plane...) or you want to improve the connection speed, you can use a USB cable to connect your Android phone via USB to your computer. USB tethering or ADB USB debugging (recommended) are available. Execute: adb forward tcp:8022 tcp:8022 and you will have SSH connectivity in your 8022 port (localhost) to your Android phone:

ssh localhost -p 8022.

How to downgrade an Android app without losing data and removing it

# Download the apk before
adb push xyz.apk /data/local/tmp/
adb shell pm install -r -d /data/local/tmp/xyz.apk

DNS config

Recommended to config a private DNS from a public available one in your country or region. For example, I like : DNS4.eu.

Samsung Dex tips

Browser recommended

Brave browser) includes IA, is fast, low-battery consumption, not bad in Samsung Dex and gets a good mark in https://adblock-tester.com/

Alternative browsers

Cromite browser plus adblocking userscripts is an open source alternative. It fails for some authentication webviews, so I cannot set as my default browser.

Ironfox plus some privacy addons like uBlock Origin, Privacy Badger... is the best open source alternative for me. You may set Enhanced Tracking Protection to Standard level, because some sites like Paypal could have issues. Take into account that:

Fixing flickering/disconnecting screen when Desktop Mode on Samsung Dex

It seems WiFi + Power charging + Display on output screen + Mobile Data makes powering issues so disable Mobile Data connection fix the issue (really not needed because typically you can use WiFi or Ethernet interface).

Copy-paste

Copy&paste works mostly in apps but in terminal apps doesn't work Ctrl-v is not correct shortcut for pasting. That's a reserved key combination. In Termux works:

  • Paste: Ctrl+Alt+V

Termux

Change font size on Samsung Dex

In Samsung DeX you cannot pinch-to-zoom, but you can adjust the font size in Termux using the keyboard shortcuts:

Ctrl + Alt + - → Decrease font size
Ctrl + Alt + = → Increase font size

Tip for Termux when Android >= 12L

Run command once to disable killing of phantom processes and processes using excessive cpu (recommeded for Termux in Android 12L or 13):

adb shell "settings put global settings_enable_monitor_phantom_procs false"

Visual Studio Code on Samsung Dex

code-server (vscode on browser)

Install code-server from Termux is easy but have a version that works is not easy:

pkg upgrade -y
pkg install nodejs-lts python yarn binutils
FORCE_NODE_VERSION=FALSE yarn global add [email protected] --ignore-engines;
sed -i -e 's|switch(process.platform)|switch("linux")|' /data/data/com.termux/files/home/.config/yarn/global/node_modules/code-server/lib/vscode/out/vs/platform/terminal/node/ptyHostMain.js

To start:

code-server --auth none 

code-oss (vscode native and opensource)

On termux:

pkg i tur-repo  
pkg i code-oss code-is-code-oss

Android Auto

AA Wireless tips

  • Disable battery optimization for Android Auto app
  • Wi-Fi -> Intelligent Wi-Fi: disable Change to better Wi-Fi networks

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment