How to Connect To Android via USB

Original forum link
https://forum.qubes-os.org/t/32450
Original poster
cubicpyramid
Created at
2025-02-21 01:43:36
Posts count
2
Likes count
3

I have used two approaches: one for using USB MTP (via sys‑usb) and one for accessing Android devices via FTP/SFTP over tethering.

Security Considerations: - When using USB MTP, disconnect unnecessary USB devices before connecting your phone, then restart sys‑usb afterward to ensure a clean state.
- For FTP/SFTP, running the file access in a dedicated, isolated qube keeps any potential network-based risks away from your core systems.

Choosing Between Methods:
- USB MTP: May offer faster speeds and direct file system access—but can be finicky in Qubes due to USB passthrough issues.
- FTP/SFTP: Provides an alternative that uses the phone’s network interface; though speeds are typically lower (especially if tethering via 2.4 GHz), it benefits from the isolation of using a dedicated qube.

Method 1: Using USB MTP via sys‑usb

Overview:
The goal is to have your Android device (in MTP mode) work reliably through the sys‑usb qube. This method requires that your sys‑usb’s disposable VM (DVM) template has the proper MTP support packages installed.

IMPORTANT PREPARATION (for security):
- Disconnect Extra USB Devices:
To reduce potential conflicts and minimize the attack surface, disconnect any nonessential USB devices (e.g. wireless mice, extra peripherals) before connecting your Android device.
- Restart sys‑usb After the Operation:
Once you’ve finished transferring files, restart sys‑usb to revert any temporary USB assignments.


Step 1. Determine Your Template Type


Step 2. Install MTP Support Packages in the Template

For Fedora‑based Templates

Open a terminal in your Fedora template (or update it via dom0) and install:

sudo dnf install gvfs-mtp libmtp

Note: Fedora repositories do not provide a separate “mtp-tools” package. The combination above enables MTP support in file managers (such as Thunar, which is used in Qubes OS).

For Debian‑based Templates

Open a terminal in your Debian template and run:

sudo apt update
sudo apt install gvfs-backends mtp-tools

Note: In Debian, these packages add MTP support so that file managers can mount and browse your Android device.


Step 3. Restart the Template and sys‑usb

After installing the packages, shut down the template and restart sys‑usb so that the changes take effect:

qvm-shutdown sys-usb && qvm-start sys-usb

Step 4. Connect and Use Your Android Device

  1. On Your Android Device:
  2. Enable USB file transfer (MTP).
  3. Make sure the device is unlocked.

  4. Physically Connect the Device:

  5. Plug it into your computer's USB port.
  6. (Remember: disconnect other USB devices first for safety.)

  7. Verify in sys‑usb:

  8. Open a terminal or Thunar file manager in sys‑usb.
  9. Run lsusb (or check Thunar’s Devices list) to ensure the Android device appears.
  10. You should now be able to browse the phone’s storage via MTP.

  11. After You’re Done:

  12. Restart sys‑usb to reset the USB state:
    qvm-shutdown sys-usb && qvm-start sys-usb
    

Method 2: Accessing the Android Device via FTP/SFTP Over Tethering

Overview:
If MTP remains unreliable or you prefer an alternative, you can run an FTP (or SFTP) server on your Android device. By enabling tethering (hotspot) on the phone, you can connect from a dedicated qube (not sys‑usb) and use Thunar to browse files over the network.


Step 1. Set Up an FTP/SFTP Server on the Android Device

  1. Install an FTP/SFTP Server App:
  2. Enable Tethering:
  3. Activate the phone’s hotspot/tethering feature so that your computer can join its network.
  4. Configure the Server:
  5. Follow the app’s instructions to start the server (note the IP address and port it uses).

Step 2. Prepare Your Dedicated Qube for Network File Access

Use a dedicated qube (separate from sys‑usb) that will access the phone via its hotspot.

For Fedora‑based Dedicated Qubes

Open a terminal in the Fedora template used by the dedicated qube and install:

sudo dnf install gvfs gvfs-ftp

Note: The “gvfs-ftp” package (or FTP backend integrated with gvfs) allows Thunar to access FTP URLs.

For Debian‑based Dedicated Qubes

Open a terminal in the Debian template for your dedicated qube and run:

sudo apt update
sudo apt install gvfs-backends

This package includes support for FTP/SFTP access in file managers.


Step 3. Connect to Your Android Device Over FTP/SFTP

  1. Join the Hotspot:
  2. On the dedicated qube, connect to the Android phone’s hotspot.
  3. Access the FTP/SFTP Server:
  4. Open Thunar.
  5. In the location bar, enter the server address. For FTP it might be:
    ftp://<phone_ip>:<port>/
    
    For SFTP, use:
    sftp://<phone_ip>:<port>/
    
  6. Browse and Transfer Files:
  7. Once connected, you should be able to view and transfer files as needed.