scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

[Question] how should I connect securely while using a USB hub?

Open ShapeShifter499 opened this issue 2 years ago • 8 comments

The setup currently: A Z Fold 4 connected to a USB hub for some devices including a yubikey with a dummy HDMI adapter to trigger DeX mode. An Acer c710 chromebook modified to run Arch Linux directly (no Chrome OS). I'm wanting to use the chromebook as a sort of lapdock for a little bigger screen and keyboard.

Someone correct me if I'm wrong but it doesn't seem like I can use a USB Type-C hub at the same time as a wired ADB connection. If I understand things correctly ADB wireless wouldn't be secure if I wanted to use this set up while traveling and using something like a coffee shop wifi connection. How should I connect securely in this type of situation?

ShapeShifter499 avatar Dec 09 '22 07:12 ShapeShifter499

Someone correct me if I'm wrong but it doesn't seem like I can use a USB Type-C hub at the same time as a wired ADB connection.

Why not? Maybe I misunderstood, but as soon your machine running arch linux is connected via usb to your device, adb should work I guess.

rom1v avatar Dec 09 '22 08:12 rom1v

@rom1v what I meant was having the phone connected to a USB hub at the same time as it's connected over wire to a PC for adb and scrcpy. That way I could use USB devices, like the yubikey, with the phone while avoiding having adb and scrcpy exposed to the public network or Wifi when traveling.

I'm guessing that's not possible?

So what would be a more secure workaround?

ShapeShifter499 avatar Dec 09 '22 10:12 ShapeShifter499

So you plug a USB switch (is it really a hub?) on your laptop, and plug the device on it:

                      |--- USB hard drive
laptop --- USB switch |--- Android device
                      |--- Yubikey
                      |--- …

Is it correct?

rom1v avatar Dec 09 '22 10:12 rom1v

So you plug a USB switch (is it really a hub?) on your laptop, and plug the device on it:

                      |--- USB hard drive
laptop --- USB switch |--- Android device
                      |--- Yubikey
                      |--- …

Is it correct?

No

                            |--- HDMI dummy connector
Android Phone --- USB C hub |--- Yubikey
                            |--- USB thumb drive

The hub is directly attacted to the phone. I was only inquiring if there was a way to allow a adb wired connection to the PC with this setup. Or if I might have to get a specific cable or hub.

I only wanted this because I thought adb might be insecure to use over a public wifi network (like starbucks) if I were traveling. But according to this https://stackoverflow.com/questions/35981651/access-control-for-adb-connection-of-phone/35989150#35989150 it seems maybe it uses similar key set up to SSH so after the inital authorization using a usb connection, adb wireless will use the key to encrypt the connection locally. But I want to confirm I understand that.

ShapeShifter499 avatar Dec 09 '22 10:12 ShapeShifter499

I thought adb might be insecure to use over a public wifi network

The adb connection is authenticated, so no one should be able to get an adb access (unless you authorize them explicitly when they try to connect). However, it is insecure in that the connection is not encrypted, so everything you do on the wire is in clear: https://android.stackexchange.com/questions/172573/is-wireless-adb-encrypted

rom1v avatar Dec 09 '22 11:12 rom1v

I thought adb might be insecure to use over a public wifi network

The adb connection is authenticated, so no one should be able to get an adb access (unless you authorize them explicitly when they try to connect). However, it is insecure in that the connection is not encrypted, so everything you do on the wire is in clear: https://android.stackexchange.com/questions/172573/is-wireless-adb-encrypted

Okay then, so in public the most secure option is just to have the phone directly attached to the computer with a usb cable. But I can't use other usb devices directly with the phone in this case as far as I know. I think I'm stuck between using the bigger screen and keyboard or allowing for USB devices attached to the phone.

ShapeShifter499 avatar Dec 09 '22 11:12 ShapeShifter499

You can connect a USB to Ethernet Adapter to your USB Hub. Android Phone --- USB C hub |--- USB-Ethernet Adapter --- Ethernet Cable ---| PC Ethernet

The PC Ethernet can be also a USB-Adapter or a docking dtation etc. After this you can use the ADB via network

sh-hilden avatar Dec 09 '22 12:12 sh-hilden

If Miraclecast is compatible with your Chromebook, you can use that instead to trigger DeX wirelessly. You can eliminate the need of using a dummy HDMI. You can then run a cable to your Chromebook and mirror DeX with display id 2 scrcpy -d --display 2. You can't attach USB devices to your phone though.

You may be able to disconnect the cable temporarily and use the hub to copy files or use yubikey, navigate with miraclecast for the meantime (I heard it does support UIBC which allows input), then return back to wired scrcpy for higher quality and low latency mirroring.

4nric avatar Dec 10 '22 06:12 4nric

Did you ever figure out a solution to getting USB adb while using a USB C hub on your phone?

This would be the ideal setup for lowest latency:

                            |--- HDMI dummy plug
Android Phone --- USB C hub |--- USB storage drive
                            |----------usb-adb---------- laptop
  • So far, I can do scrcpy over tcpip with the HDMI dummy plug connected via USB C to the phone.
  • I can also do scrcpy over USB while the phone is connected to an unrelated miracast display (only using it to enable desktop mode), but this does not allow for other peripherals to be connected, and requires another display to be on.
  • I suppose I could also do scrcpy over tcpip when connected to miracast for a totally wireless solution, but this is basically the opposite of what I want.

My guess is that this is not possible because the phone needs to be a host and peripheral at the same time through the hub, which probably is not supported. https://developer.android.com/develop/connectivity/usb#debug_considerations

I may get USB ethernet adapter to try that suggestion.

I guess another approach to this would be to somehow enable the desktop display mode without any display (or dummy plug) connected, but I do not think this is possible at the moment.

mwaterbu avatar Mar 07 '24 04:03 mwaterbu

The old ADB over Wi-Fi is unencrypted, but the new wireless debugging added in Android 11 is encrypted using TLS, so that should be safe in public Wi-Fi.

yume-chan avatar Mar 07 '24 11:03 yume-chan

For avoiding wireless, I am more concerned with lowering latency than security, as I will not be using this outside of my home network.

mwaterbu avatar Mar 09 '24 23:03 mwaterbu