Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
kaefert opened this issue May 23, 2020 · 4 comments · May be fixed by #1741
Open
1 task done

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

kaefert opened this issue May 23, 2020 · 4 comments · May be fixed by #1741

Comments

@kaefert
Copy link

kaefert commented May 23, 2020

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


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
Copy link
Author

kaefert commented May 23, 2020

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

@rom1v
Copy link
Collaborator

rom1v commented May 24, 2020

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 #100 (comment), a project which adb-connects to an Android device from another Android device. It should work to connect to localhost too in theory.

@excitoon excitoon linked a pull request Sep 6, 2020 that will close this issue
@maya-56
Copy link

maya-56 commented Dec 21, 2022

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. ?

@e-t-l
Copy link

e-t-l commented Sep 4, 2024

If you just want to adb to a remote device, you can install a private VPN on both devices (e.g. TailScale, ZeroTier, Netmaker), then connect wireless ADB with your phone's intranet address.

SSH would still be a better solution, though. While the above VPNs are end-to-end encrypted, ADB is still a plaintext protocol, while SSH has very strong encryption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants