scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Scrcpy via ssh directly to android device (no computer+usb in between)

Open kaefert opened this issue 5 years ago • 3 comments

Hi there!

Thanks for this wonderful piece of software! It works absolutely amazing via USB, perfect quality, super low latency, simply amazing for controlling my phone through my computer! Much better than any device emulator I've seen! :)

Now I also have an android media player remote somewhere that I can connect to directly via ssh (installed and started through Termux) which I'd like to remote control using scrcpy


  • [x] I have checked that a similar feature request does not already exist.

Is your feature request related to a problem? Please describe. See above and below.

Describe the solution you'd like Connect directly to android device via ssh without computer with usb-connection in between. I can't use wireless adb without ssh, because the internet is in between and only the ssh port is forwarded through the NATing router.

Describe alternatives you've considered Running tsudo screencap -p see.png ; tsudo chmod 666 see.png on the device and then using sftp to look at the image. When I need to click something I use su -c input tap $x $y. That method is very slow and annoying for manual control though.

Additional context The android media player is used to drive a public display of sorts, and most of the time I try to avoid going there for maintance and instead use ssh+sftp.

All I could find relating to scrcpy + ssh seems to talk about the scenario where you have a remote computer that's connected to the android device via usb and the local computer connects to the remote one via ssh and uses port forwards through the ssh tunnel to access the adb server on that computer to talk to the android device.

There's also some information how to use wireless adb for Scrcpy but I couldn't find anything on how to do it through ssh without a computer with adb server on the remote locaton.

kaefert avatar May 23 '20 08:05 kaefert

So I did some more research and found the following related threads: Wireless connection on same network: https://github.com/Genymobile/scrcpy/issues/5 Connect via ssh port forward and remote computer+usb: https://github.com/Genymobile/scrcpy/issues/144 Also ssh port forwarding to remote computer+usb (I think, not 100% sure): https://github.com/Genymobile/scrcpy/issues/242 This is also about ssh directly to android, but I don't see a solution: https://github.com/Genymobile/scrcpy/issues/289 And here's a blog entry about Scrcpy via wireless adb on same network.

kaefert avatar May 23 '20 11:05 kaefert

The scrcpy client necessarily connects to the device via adb. In particular, it executes the scrcpy server via adb shell to get shell permissions (to capture the video without asking and to inject events).

If from your shell you can see your device via adb devices, then you could use scrcpy. Maybe you could adb connect to localhost. You could check https://github.com/Genymobile/scrcpy/issues/100#issuecomment-404186710, a project which adb-connects to an Android device from another Android device. It should work to connect to localhost too in theory.

rom1v avatar May 24 '20 21:05 rom1v

Hello Team,

Still we have any clear steps for connecting devices running on another network.

For example:

  1. Have a windows PC in India.
  2. Android device running on USA.

I want to connect that device from My windows PC using Scrcpy. I know the public IP address of the remote device.

Anyone can you please help me. ?

maya-56 avatar Dec 21 '22 18:12 maya-56