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

use SSH properly to remote port forwarding

Tue Jun 14, 2016 3:41 pm

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, and it works perfect.

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 think use SSH is kind of the best solution, and I actually do not quite know other solutions.

Pi -> Server -> PC

in Pi: ssh -f -N -R 7575:192.168.1.2:7575 root@100.111.111.111 (is this the correct way ??)

in PC: ssh -D 7575 root@100.111.111.111 (is this correct ??)
or PC: ssh -L -N -f 7575:100.111.111.111:7575 root@100.111.111.111 (or I should do this??)

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

Am I on the right track?

Have been cost a week on this. Feel really stressful. Really need help.

Thanks you all in advance.

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 3:49 pm

Can you reach your "host server" via ssh from both pi and PC?
Can your host server ping the pi at 192.68.1.2?
Can your host server ping the PC at 192.68.0.55?

Do I understand you correctly that you want an USB device that is physically attached to the pi from your PC? And that you achieved this when both were in the same network/subnet by letting the PC connect to the pi 192.168.0.44:7575?

rayjoh
Posts: 27
Joined: Thu May 23, 2013 11:48 am

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 4:17 pm

Verify that port 7575 is unused on server
netstat -l -n

Ports over 1024 can be used by non-root users. Try first without "-N -f".
On pi
ssh -R 7575:localhost:7575 usbuser@100.111.111.111 (localhost is on pi)
On PC
ssh -L 7575:localhost:7575 usbuser@100.111.111.111 (localhost is on server)

springyulei wrote: or PC: ssh -L -N -f 7575:100.111.111.111:7575 root@100.111.111.111 (or I should do this??)
"-N -f" can not be between "-L" and "7575...."
-- Raymond

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

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 4:29 pm

dasmanul wrote:Can you reach your "host server" via ssh from both pi and PC?
Can your host server ping the pi at 192.68.1.2?
Can your host server ping the PC at 192.68.0.55?

Do I understand you correctly that you want an USB device that is physically attached to the pi from your PC? And that you achieved this when both were in the same network/subnet by letting the PC connect to the pi 192.168.0.44:7575?

Hi, thanks for your reply.

sorry, I actually can not ping the pi at 192.168.1.2 in my host server.

I am trying to figure out why. But seems like not really working.

I add extra ssh port 7576 on Raspberry pi
and I can not even use ssh -R 7599:192.168.1.2:7576 test_user@100.111.111.111
it will tells me connection timed out.

I will try to make ssh connect works first. I used to use localhost:7576 to connect with host server, and in that time, I could remote connect pi from Server by ssh -p 7599 pi@localhost


Yes, you are understanding it right. With some software for Share Usb over network could let you attache a usb with pi but controlled by your PC.

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

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 4:32 pm

rayjoh wrote:Verify that port 7575 is unused on server
netstat -l -n

Ports over 1024 can be used by non-root users. Try first without "-N -f".
On pi
ssh -R 7575:localhost:7575 usbuser@100.111.111.111 (localhost is on pi)
On PC
ssh -L 7575:localhost:7575 usbuser@100.111.111.111 (localhost is on server)

springyulei wrote: or PC: ssh -L -N -f 7575:100.111.111.111:7575 root@100.111.111.111 (or I should do this??)
"-N -f" can not be between "-L" and "7575...."

hi, thanks.

You are right, my ssh connect now has problem. I will try your method first, and let you the result. But I tried use localhost:7575 before, and host server could remotely control the pi for sure. But, at that time, I do not know how to find the usb ip. because 127.0.0.1:7575 will not be the pi's usb ip, but might be the host server ip

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

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 4:51 pm

rayjoh wrote:Verify that port 7575 is unused on server
netstat -l -n

Ports over 1024 can be used by non-root users. Try first without "-N -f".
On pi
ssh -R 7575:localhost:7575 usbuser@100.111.111.111 (localhost is on pi)
On PC
ssh -L 7575:localhost:7575 usbuser@100.111.111.111 (localhost is on server)

springyulei wrote: or PC: ssh -L -N -f 7575:100.111.111.111:7575 root@100.111.111.111 (or I should do this??)
"-N -f" can not be between "-L" and "7575...."

Hi, i am confused now. and sorry for my error port description.

so, I am doing this now:
pi has ssh port 22 and 7576
server has ssh port 22 and 7576

on pi:
sudo ssh -R 7599:localhost:7576 user@100.111.111.111 (this connection succeed )
on PC:
used putty to set the command, set tunnel used local with port 7599,
and the host is 100.111.111.111 and port is 22. the command might like this:
ssh -L 22:localhost:7599 root@100.111.111.111 (i could login by enter root password)
and i can use ssh -p 7599 pi@localhost to remotely login pi
But I do not know what should I do now. How to find the ip of the pi.

I

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 5:08 pm

Well, if you're confused, it might be worth trying what people suggest on this thread instead of experimenting with somewhat similar commands on your own. So, to quote rayjoh's excellent reply:
rayjoh wrote:Verify that port 7575 is unused on server
netstat -l -n

On pi
ssh -R 7575:localhost:7575 usbuser@100.111.111.111 (localhost is on pi)
On PC
ssh -L 7575:localhost:7575 usbuser@100.111.111.111 (localhost is on server)
The pi's USB should then be reachable on the PC at localhost:7575 (or 127.0.0.1:7575).

Please note that it will also be reachable at 100.111.111.111:7575 to everybody who can reach that port on your server.

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

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 5:18 pm

dasmanul wrote:Well, if you're confused, it might be worth trying what people suggest on this thread instead of experimenting with somewhat similar commands on your own. So, to quote rayjoh's excellent reply:
rayjoh wrote:Verify that port 7575 is unused on server
netstat -l -n

On pi
ssh -R 7575:localhost:7575 usbuser@100.111.111.111 (localhost is on pi)
On PC
ssh -L 7575:localhost:7575 usbuser@100.111.111.111 (localhost is on server)
The pi's USB should then be reachable on the PC at localhost:7575 (or 127.0.0.1:7575).

Please note that it will also be reachable at 100.111.111.111:7575 to everybody who can reach that port on your server.

Thanks.

Yes, I followed that. I say similar is because I am not sure if putty on Windows is doing that exactly commands. But, as i said, i set putty use tunnel with Local and 127.0.0.1:7599

I confused the port number too, so I changed to use 7599.

On pi
ssh -R 7599:localhost:7576 usbuser@100.111.111.111 (localhost is on pi)
On PC
ssh -L 22:localhost:7599 usbuser@100.111.111.111 (localhost is on server) I am not sure if its 22, but in putty i set host and port 22.

then i logged into the host server by enter username and password.

could you tell how to test the reachable on the PC at localhost:7575 (or 127.0.0.1:7575).

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 5:28 pm

Can you post a screenshot of your putty settings?

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 5:31 pm

springyulei wrote:Yes, I followed that.
No, you didn't. At least I don't see the output of netstat -l -n on your server anywhere in your posts so there's no way for anybody to know what you did.

Also, you changed port numbers around in the commands given to you without knowing what you're doing - this will of course lead to the USB being reachable on a different port (if at all).

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

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 5:34 pm

dasmanul wrote:Can you post a screenshot of your putty settings?
Yes
Attachments
2.PNG
tunnel setting
2.PNG (35.62 KiB) Viewed 4990 times
1.PNG
putty
1.PNG (35.88 KiB) Viewed 4990 times

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

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 5:37 pm

dasmanul wrote:
springyulei wrote:Yes, I followed that.
No, you didn't. At least I don't see the output of netstat -l -n on your server anywhere in your posts so there's no way for anybody to know what you did.

Also, you changed port numbers around in the commands given to you without knowing what you're doing - this will of course lead to the USB being reachable on a different port (if at all).

attached is the netstat -l -n

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

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 5:39 pm

springyulei wrote:
dasmanul wrote:
springyulei wrote:Yes, I followed that.
No, you didn't. At least I don't see the output of netstat -l -n on your server anywhere in your posts so there's no way for anybody to know what you did.

Also, you changed port numbers around in the commands given to you without knowing what you're doing - this will of course lead to the USB being reachable on a different port (if at all).

attached is the netstat -l -n
Attachments
3.PNG
netstat -l -n
3.PNG (11.57 KiB) Viewed 4920 times

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 5:50 pm

There seem to be a lot of ssh connections listening on your server now, probably remnants from your earlier attempts. Could you try terminating all of these? To do that:

- Enter "sudo killall ssh" on the pi.
- Terminate all putty windows on the PC

You can verify that by entering "netstat -l -n" again on your server. Many of the entries should be gone.

Then, please enter the following on your pi:

ssh -R 7599:localhost:7575 user@100.111.111.111

On the PC, connect to your server via putty with the settings you showed in the screenshot.

Your pi's USB should then be reachable from the PC at localhost:7599 (or 127.0.0.1:7599).

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

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 5:53 pm

dasmanul wrote:There seem to be a lot of ssh connections listening on your server now, probably remnants from your earlier attempts. Could you try terminating all of these? To do that:

- Enter "sudo killall ssh" on the pi.
- Terminate all putty windows on the PC

You can verify that by entering "netstat -l -n" again on your server. Many of the entries should be gone.

Then, please enter the following on your pi:

ssh -R 7599:localhost:7575 user@100.111.111.111

On the PC, connect to your server via putty with the settings you showed in the screenshot.

Your pi's USB should then be reachable from the PC at localhost:7599 (or 127.0.0.1:7599).

Thank you. I will follow these steps.

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 5:57 pm

Good luck and let us know whether they work!

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

Re: use SSH properly to remote port forwarding

Tue Jun 14, 2016 10:05 pm

dasmanul wrote:Good luck and let us know whether they work!
Sure, I will let you all know the results.

But, Currently, still not working.

I think the problem is like what happened under same router:
The PC can find it by 192.168.0.44:7575 , however, 127.0.0.1:7575 can not work.

So, I feel, even I have ssh tunnel to the pi, I am only able to use 127.0.0.1 which can not work.
Because 127.0.0.1 and 192.168.x.x is different. 192.168.x.x is assigned by router, right?

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

Re: use SSH properly to remote port forwarding

Wed Jun 15, 2016 5:28 am

Hi all,

I have send email to contact the Virtual Here Sharing USB Over Internet. And they are recommending me to use router port forwarding. I think I will just do that.

Thanks you all, I really appreciate all of your time.

Best,

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: use SSH properly to remote port forwarding

Wed Jun 15, 2016 7:46 am

springyulei wrote:Sure, I will let you all know the results.
Good!
But, Currently, still not working.
So you did exactly what I wrote in my last post and it didn't work? In what way did it not work? Did you get any error messages?
I think the problem is like what happened under same router:
The PC can find it by 192.168.0.44:7575 , however, 127.0.0.1:7575 can not work.
No, that is not the same problem.
So, I feel, even I have ssh tunnel to the pi, I am only able to use 127.0.0.1 which can not work.
Because 127.0.0.1 and 192.168.x.x is different. 192.168.x.x is assigned by router, right?
127.0.0.1 is localhost - that is the computer on which you issue the command. So, in the case of your PC, 127.0.0.1 is the PC itself. Conneting to that will only work if an ssh tunnel is set up from the PC to the server and from the server to your pi. That's the purpose of the commands proposed in this thread.

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

Re: use SSH properly to remote port forwarding

Wed Jun 15, 2016 11:54 am

springyulei wrote:Hi all,

I have send email to contact the Virtual Here Sharing USB Over Internet. And they are recommending me to use router port forwarding. I think I will just do that.

Thanks you all, I really appreciate all of your time.

Best,
This is exactly what I explained to you in your other post on this subject. You have to tell your network equipment how and where to route the traffic to the other Pi.
You can run, but you will only die tired.

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

Re: use SSH properly to remote port forwarding

Wed Jun 15, 2016 2:14 pm

Romonga wrote:
springyulei wrote:Hi all,

I have send email to contact the Virtual Here Sharing USB Over Internet. And they are recommending me to use router port forwarding. I think I will just do that.

Thanks you all, I really appreciate all of your time.

Best,
This is exactly what I explained to you in your other post on this subject. You have to tell your network equipment how and where to route the traffic to the other Pi.
You were right. Thanks man.

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

Re: use SSH properly to remote port forwarding

Wed Jun 15, 2016 3:24 pm

dasmanul wrote:
springyulei wrote:Sure, I will let you all know the results.
Good!
But, Currently, still not working.
So you did exactly what I wrote in my last post and it didn't work? In what way did it not work? Did you get any error messages?
I think the problem is like what happened under same router:
The PC can find it by 192.168.0.44:7575 , however, 127.0.0.1:7575 can not work.
No, that is not the same problem.
So, I feel, even I have ssh tunnel to the pi, I am only able to use 127.0.0.1 which can not work.
Because 127.0.0.1 and 192.168.x.x is different. 192.168.x.x is assigned by router, right?
127.0.0.1 is localhost - that is the computer on which you issue the command. So, in the case of your PC, 127.0.0.1 is the PC itself. Conneting to that will only work if an ssh tunnel is set up from the PC to the server and from the server to your pi. That's the purpose of the commands proposed in this thread.
Thank you very much. you are right.

I just tested, installed Virutalhere Server and Client on my PC, and the client could find the USB by 127.0.0.1:7575 and by 192.168.0.55:7575

Which means, My problem is I did not make the ssh tunnel without password, right?

So, I have SSH -R to Host Server on Pi, and it made me could directly use Putty to connect 100.111.111.111:7575, and I can login with user name pi and password raspberry

However, If I only use 100.111.111.111:7575 as address in Virtualhere on PC, it cannot working as I did not enter password, right?

So, I need find a way to make any connection passed through 100.111.111.111:7575 all without password??

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

Re: use SSH properly to remote port forwarding

Wed Jun 15, 2016 4:40 pm

Romonga wrote:
springyulei wrote:Hi all,

I have send email to contact the Virtual Here Sharing USB Over Internet. And they are recommending me to use router port forwarding. I think I will just do that.

Thanks you all, I really appreciate all of your time.

Best,
This is exactly what I explained to you in your other post on this subject. You have to tell your network equipment how and where to route the traffic to the other Pi.


I just did a router port forwarding. And I check "can you see me" to test my port, and its not opened. Do you know what else I need to do on the Pi ?

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

Re: use SSH properly to remote port forwarding

Wed Jun 15, 2016 5:54 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”