springyulei
Posts: 27
Joined: Wed Jun 01, 2016 5:37 pm

How to ssh Raspberry Pi usb remotely from other place

Mon Jun 13, 2016 5:27 pm

Hi, I am using raspberry pi connected a usb device, and then used a Share USB over Internet software to share the usb so that i can use windows software to control the usb device. the device use port 7575

It works perfect when the pi is under the same router, like at home.

But, how I can make the pi works for me in other place.

I think the solutions should be use SSH, or OpenVPN ?
I am not familiar with these. I tried OpenVPN, but it is really too complicated to set up and I failed.
Then I am trying to use SSH.

I used SSH -R 9999:localhost:9999 [email protected] to create a port forwarding from my own server to my pi

Then I think I should use SSH -D to create proxy tunnel to my server on Windows so that my windows app could connect to the server.

but, in this way, I only could connect to the server, but can not find the shared USB.

Is there anything I am worong?

should I create a proxy tunnel from server to pi, and let shared usb port 7575 all go through the proxy tunnel?

Romonga
Posts: 123
Joined: Mon May 09, 2016 7:09 pm
Location: Montgomery Il

Re: How to ssh Raspberry Pi usb remotely from other place

Mon Jun 13, 2016 6:24 pm

I think what you want is an SSH tunnel. As I have done this in the past I will point you to a good article on this.

http://www.ytechie.com/2008/05/set-up-a ... s-or-less/

Keep In Mind that to do this outside your network will require some port forwarding on your router.
You can run, but you will only die tired.

springyulei
Posts: 27
Joined: Wed Jun 01, 2016 5:37 pm

Re: How to ssh Raspberry Pi usb remotely from other place

Mon Jun 13, 2016 6:34 pm

Romonga wrote:I think what you want is an SSH tunnel. As I have done this in the past I will point you to a good article on this.

http://www.ytechie.com/2008/05/set-up-a ... s-or-less/

Keep In Mind that to do this outside your network will require some port forwarding on your router.

hey, thanks for your reply. But I feel that does not helping me. I am totally lost

springyulei
Posts: 27
Joined: Wed Jun 01, 2016 5:37 pm

Re: How to ssh Raspberry Pi usb remotely from other place

Tue Jun 14, 2016 3:37 pm

Romonga wrote:I think what you want is an SSH tunnel. As I have done this in the past I will point you to a good article on this.

http://www.ytechie.com/2008/05/set-up-a ... s-or-less/

Keep In Mind that to do this outside your network will require some port forwarding on your router.


Hi, I still can not solve it. I think I just so close.

SO, I have PC(192.168.0.55), host server(100.111.111.111), pi (192.168.1.2 or when in the same router 192.168.0.44)

when the pi and the PC under same router, the Virtual Here Share USB over Internet could easily find the shared usb ip: 192.168.0.44:7575

Now, I made Pi connect with a different network. its internal ip changed to 192.168.1.2 and the public ip also changed for sure.

I still think use SSH is kind of the best solution. Pi -> Server -> PC

in Pi: ssh -f -N -R 7575:192.168.1.2:7575 [email protected] (is this the correct way ??)

in PC: ssh -D 7575 [email protected] (is this correct ??)
or PC: ssh -L -N -f 7575:100.111.111.111:7575 [email protected] (or I should do this??)

The goal is my PC side USB Virtual Here could find the ip of the Pi shared USB.

Why insist using SSH? I do not want edit Router to do the port forward. Because there are so many different router.

Am I on the right track?

Have been cost a week on this. Feel really stressful

Romonga
Posts: 123
Joined: Mon May 09, 2016 7:09 pm
Location: Montgomery Il

Re: How to ssh Raspberry Pi usb remotely from other place

Tue Jun 14, 2016 3:59 pm

If your Pi is on the inside of your router and you are trying to access the Pi from the outside of your router, you have no choice put to find a way to pass the traffic to the device. This is normally done with port forwarding at your router.

You could also create a VPN tunnel, however yet again, it does require you to open up and forward ports on your firewall.
You can run, but you will only die tired.

User avatar
faramon
Posts: 123
Joined: Sat Jun 11, 2016 8:36 am
Location: Croatia

Re: How to ssh Raspberry Pi usb remotely from other place

Tue Jun 14, 2016 4:29 pm

Only need is to port forward on router to 5901 if you use THIGHTVNC like myself and thats it.
I have NGINX server instaled, port forward on port 5901 and 80 for http connection and that is all i have done.
Some routers do not allow connection from out, in this case must to do DMZ (demilitary zone) for that.

Faramon

springyulei
Posts: 27
Joined: Wed Jun 01, 2016 5:37 pm

Re: How to ssh Raspberry Pi usb remotely from other place

Tue Jun 14, 2016 6:00 pm

Romonga wrote:If your Pi is on the inside of your router and you are trying to access the Pi from the outside of your router, you have no choice put to find a way to pass the traffic to the device. This is normally done with port forwarding at your router.

You could also create a VPN tunnel, however yet again, it does require you to open up and forward ports on your firewall.

Thank you. I just feel its too complicated.

springyulei
Posts: 27
Joined: Wed Jun 01, 2016 5:37 pm

Re: How to ssh Raspberry Pi usb remotely from other place

Tue Jun 14, 2016 6:00 pm

faramon wrote:Only need is to port forward on router to 5901 if you use THIGHTVNC like myself and thats it.
I have NGINX server instaled, port forward on port 5901 and 80 for http connection and that is all i have done.
Some routers do not allow connection from out, in this case must to do DMZ (demilitary zone) for that.

Faramon

Thank you. So, I only need install TightVNC on Raspberry Pi ?

Tzarls
Posts: 224
Joined: Tue Feb 26, 2013 6:59 am

Re: How to ssh Raspberry Pi usb remotely from other place

Tue Jun 14, 2016 7:56 pm

The solution to your problem might be to create a reverse ssh tunnel from the pi to your server in such a way that any data sent to your server´s port 7575 is routed to the pi´s port 7575 automatically - no need to do port forwarding on your router or anything like that. By reading your posts it looks like you´ve been trying that approach. Keep in mind that once the tunnel is established you don´t need to ssh into the server to use the tunnel - just point your shared usb software at your server @ 7575 - this will in turn point to your pi´s 7575. BUT this will only work if your server is reachable from the outside. In other words, if the Pi can always reach your server and the PC can always reach your server then you can have this setup working. I find it easier that trying to configure OpenVPN.

Of course this will leave your USB available to anyone reaching your server at port 7575. Does your USB sharing software have some kind of authentication methods? (Passwords or anything like that before accesing the shared data)?

Check here:
http://www.tunnelsup.com/raspberry-pi-p ... ssh-tunnel

User avatar
faramon
Posts: 123
Joined: Sat Jun 11, 2016 8:36 am
Location: Croatia

Re: How to ssh Raspberry Pi usb remotely from other place

Tue Jun 14, 2016 8:03 pm

I had the same problem when I first installed the ThightVNC. I tried to connect from outside the Raspberry and unsuccessfully until I configured the router to forward port 5901, and now, I'am able to connects to Raspberry Pi.
Here are two things to do, first, to install TightVNC and the other, some DynDNS client have to be installed because Raspberry Pi needs to get its dynamic IP address.
So, TightVNC and DynDNS ( NO-IP in my case) and that is all you need.

Here are two links to help with no-ip:
http://www.awesomeweirdness.com/project ... pberry-pi/
http://raspisimon.dlinkddns.com/noip.php

and here is instalation steps for ThightVNC:
https://www.raspberrypi.org/documentati ... ccess/vnc/
When ThightVNC is installed then search google for STARTING ThightVNC at startup.

I hope I helped, let me know.

springyulei
Posts: 27
Joined: Wed Jun 01, 2016 5:37 pm

Re: How to ssh Raspberry Pi usb remotely from other place

Tue Jun 14, 2016 8:43 pm

Tzarls wrote:The solution to your problem might be to create a reverse ssh tunnel from the pi to your server in such a way that any data sent to your server´s port 7575 is routed to the pi´s port 7575 automatically - no need to do port forwarding on your router or anything like that. By reading your posts it looks like you´ve been trying that approach. Keep in mind that once the tunnel is established you don´t need to ssh into the server to use the tunnel - just point your shared usb software at your server @ 7575 - this will in turn point to your pi´s 7575. BUT this will only work if your server is reachable from the outside. In other words, if the Pi can always reach your server and the PC can always reach your server then you can have this setup working. I find it easier that trying to configure OpenVPN.

Of course this will leave your USB available to anyone reaching your server at port 7575. Does your USB sharing software have some kind of authentication methods? (Passwords or anything like that before accesing the shared data)?

Check here:
http://www.tunnelsup.com/raspberry-pi-p ... ssh-tunnel


Thanks.

So, I feel you got my point.
Based on your advises, I should only use SSH -R 7588:192.168.1.2:7575 [email protected] (do I need -N ?)
I have tried this, my PC client software could likely ping to there, but can not find the usb
Why I am using 192.168.1.2 instead of localhost
Because, under the same router, my PC client software could find the USB by 192.168.0.44:7575. But it could not find it by 127.0.0.1:7575 .

Tzarls
Posts: 224
Joined: Tue Feb 26, 2013 6:59 am

Re: How to ssh Raspberry Pi usb remotely from other place

Wed Jun 15, 2016 5:19 am

I don´t think you´re doing it right...

First: The reverse tunnel has to be created by the Pi. So the " ssh -N -R etc etc etc " line must be run on the pi. And yes, you need the -N. Actually there are a few more options that could be useful:

Code: Select all

/usr/bin/ssh -o ServerAliveInterval=15 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes -N -R 7575:localhost:7575 [email protected]
(Do you need to login as root?)
I use this kind of line in my own application. So, localhost refers to the Pi itself from the Pi´s own point of view.

On your PC you have to point your USB software to 100.111.111.111:7575. The software contacts your server at port 7575 and it gets routed to the Pi at port 7575. Remember that you have to first enable the automatic login with ssh certificates for this to work automatically. Did you read the link I posted?

springyulei
Posts: 27
Joined: Wed Jun 01, 2016 5:37 pm

Re: How to ssh Raspberry Pi usb remotely from other place

Wed Jun 15, 2016 5:25 am

Tzarls wrote:I don´t think you´re doing it right...

First: The reverse tunnel has to be created by the Pi. So the " ssh -N -R etc etc etc " line must be run on the pi. And yes, you need the -N. Actually there are a few more options that could be useful:

Code: Select all

/usr/bin/ssh -o ServerAliveInterval=15 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes -N -R 7575:localhost:7575 [email protected]
(Do you need to login as root?)
I use this kind of line in my own application. So, localhost refers to the Pi itself from the Pi´s own point of view.

On your PC you have to point your USB software to 100.111.111.111:7575. The software contacts your server at port 7575 and it gets routed to the Pi at port 7575. Remember that you have to first enable the automatic login with ssh certificates for this to work automatically. Did you read the link I posted?
Hi, thanks for you reply. Yes, I did. And I do have a tunnel between Pi and Host Server. And I can use my Windows PC login to the pi by 100.111.111.111.7575

But the Virtual Here USB Sharing Over Internet still can not find the shared usb ip address. So, I send email to there contact email and they just recommend me use router to port forwarding. And I think I will just use that.

Tzarls
Posts: 224
Joined: Tue Feb 26, 2013 6:59 am

Re: How to ssh Raspberry Pi usb remotely from other place

Wed Jun 15, 2016 5:39 am

One last thing, just out of curiosity: how are you running the Virtualhere Client? Are you passing it any configuration options?

springyulei
Posts: 27
Joined: Wed Jun 01, 2016 5:37 pm

Re: How to ssh Raspberry Pi usb remotely from other place

Wed Jun 15, 2016 5:44 am

Tzarls wrote:One last thing, just out of curiosity: how are you running the Virtualhere Client? Are you passing it any configuration options?

You were right. I might did not made it right. The Pi does ask authentication. At least, when I use Putty to login, I need input username, password of that Pi.

And when I use Vitualhere Client, I only provide the address. such as 127.0.0.1:7575. This might be the problem. I will try to do it now.

springyulei
Posts: 27
Joined: Wed Jun 01, 2016 5:37 pm

Re: How to ssh Raspberry Pi usb remotely from other place

Wed Jun 15, 2016 3:19 pm

Tzarls wrote:I don´t think you´re doing it right...

First: The reverse tunnel has to be created by the Pi. So the " ssh -N -R etc etc etc " line must be run on the pi. And yes, you need the -N. Actually there are a few more options that could be useful:

Code: Select all

/usr/bin/ssh -o ServerAliveInterval=15 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes -N -R 7575:localhost:7575 [email protected]
(Do you need to login as root?)
I use this kind of line in my own application. So, localhost refers to the Pi itself from the Pi´s own point of view.

On your PC you have to point your USB software to 100.111.111.111:7575. The software contacts your server at port 7575 and it gets routed to the Pi at port 7575. Remember that you have to first enable the automatic login with ssh certificates for this to work automatically. Did you read the link I posted?


Hi, I think I am lost again.

So, yes, ssh -R from my pi is what I did and it works fine.

then on my pc, the Virtualhere software only can add address 100.111.111.111:7575 , but this can not work as it should require password.

And I think above are the things you have considered.

Then what should I do. I am searching SSH tunnel without password. But, first, Virtualhere is only connecting the address, is not SSH command, right??

Then I think I should make server to Pi without password, right??

Or, I should use putty to generate key and add into Pi ssh??

springyulei
Posts: 27
Joined: Wed Jun 01, 2016 5:37 pm

Re: How to ssh Raspberry Pi usb remotely from other place

Wed Jun 15, 2016 5:53 pm

Hi All,

Thanks you all for your time.

I just found a new way to make it work. And it is super easy!!!!!!!

Weaved !!!!!!!

Install Weaved, and login to your Weaved account and then click the service you created on Pi, you will have a hostname:port to access from anywhere. super easy. 10 free remote access service. Good enough for me.

https://www.raspberrypi.org/documentati ... taccess.md

https://www.weaved.com/installing-weave ... spbian-os/


For my previous way.....I feel sorry I am too stupid. I tried forward router port, but failed, might need some other steps. I tried SSH, still failed, I only need figure out few things, but I am tired. And like others mentioned, only open ssh tunnel is not quite safe.

Anyway, I would just use this Weaved service for now.

Return to “General discussion”