Scrcpy: Connecting via SSH tunneling

Created on 23 Aug 2018  路  7Comments  路  Source: Genymobile/scrcpy

I apologize if I'm missing something. I'm attempting to make this connection over a network using SSH tunneling.

I'm setting up a local tunnel to the remote adb and then a remote tunnel from the remote scrcpy port (27183) to local using these commands:

ssh -L 5037:localhost:5037 user@<remote_ip>
ssh -R 27183:localhost:27183 user@<remote_ip>

I can successfully access ADB remotely, however when I run scrcpy it stops at "...jar 1 file pushed...". The device is running the server but it just seems like the tunnel back isn't working sufficiently.

scrcpy works on my local machine just fine and the adb reverse executes succesfully to the right port.

Update:
Adding the ssh -L 27183:localhost:27183 user@<remote_ip> tunnel produces the error: "accept: too many files".

tunnel

Most helpful comment

Thanks so much for your help I got it working. This is my solution for anyone who stumbled upon this.

OpenSSH for windows does not completely support tunnels yet, use Putty. The guide is used to set it up is below.

https://alvinalexander.com/unix/edu/putty-ssh-tunnel-firefox-socks-proxy/2-configure-putty-ssh-tunnel-ssh-server.shtml

All 7 comments

The SSH commands are correct (but you can create both tunnels at once: https://github.com/Genymobile/scrcpy/issues/144#issuecomment-414646089).

It works correctly for me.

Did you adb kill-server before starting the SSH local tunnel (I think you did, otherwise the SSH command would have failed).

Thanks for the response. Yes I made sure of that, the adb connection works flawlessly.

My setup is as follows. A windows machine with the scrcpy client, a linux box with a only the same version of adb and a phone connected to it. Maybe the linux box needs scrcpy? But I don't think so, it should just act as an intermediary.

A windows machine with the scrcpy client, a linux box with a only the same version of adb and a phone connected to it.

This is good (except the Windows part :trollface:).

Maybe the linux box needs scrcpy?

No, it does not.

I tested between 2 Debians, these port forwardings are sufficient to make it work:

ssh -CN -L5037:localhost:5037 -R27183:localhost:27183 your_remote_computer

According to your results, I would say that the remote port forwarding does not work as expected. Maybe a firewall or something.

Ok, please let me know if you ever decide to investigate this scenario using a windows box. Specifically I am using the version of OpenSSH bundled into the latest windows updates.

I have currently no windows to test, but try a simpler scenario which does not involve _scrcpy_.

On your Windows machine:

ssh -CN -R27183:localhost:27183 your_remote_computer

In another terminal on the same machine:

netcat -l -p 27183

Then, on your remote machine:

netcat localhost 27183

Then type stuff and press Return.

If the text is printed on your local machine (as the result of netcat), then the remote tunnel works.

Thanks so much for your help I got it working. This is my solution for anyone who stumbled upon this.

OpenSSH for windows does not completely support tunnels yet, use Putty. The guide is used to set it up is below.

https://alvinalexander.com/unix/edu/putty-ssh-tunnel-firefox-socks-proxy/2-configure-putty-ssh-tunnel-ssh-server.shtml

Was this page helpful?
0 / 5 - 0 ratings

Related issues

swamikamal picture swamikamal  路  3Comments

behzadpooldar picture behzadpooldar  路  4Comments

SuryaElavazhagan picture SuryaElavazhagan  路  4Comments

tonypachino picture tonypachino  路  3Comments

jonnybrooks picture jonnybrooks  路  3Comments