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

Connecting via SSH tunneling #242

Closed
obenn opened this issue Aug 23, 2018 · 7 comments
Closed

Connecting via SSH tunneling #242

obenn opened this issue Aug 23, 2018 · 7 comments
Labels

Comments

@obenn
Copy link

obenn commented Aug 23, 2018

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

@rom1v
Copy link
Collaborator

rom1v commented Aug 23, 2018

The SSH commands are correct (but you can create both tunnels at once: #144 (comment)).

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

@obenn
Copy link
Author

obenn commented Aug 23, 2018

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

@obenn
Copy link
Author

obenn commented Aug 23, 2018

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.

@rom1v
Copy link
Collaborator

rom1v commented Aug 23, 2018

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.

@rom1v rom1v added the tunnel label Aug 24, 2018
@obenn
Copy link
Author

obenn commented Aug 27, 2018

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.

@obenn obenn closed this as completed Aug 27, 2018
@rom1v
Copy link
Collaborator

rom1v commented Aug 27, 2018

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.

@obenn
Copy link
Author

obenn commented Aug 27, 2018

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

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

No branches or pull requests

2 participants