Is it possible to ssh between two different network?
How do you SSH between two different networks? Thanks in advance. Here is the scenario in question:
- My home PC IP :
192.168.1.106
- Home public IP:
XXX.YYY.ZZZ.254
- My office PC IP:
192.168.10.130
- Office public IP:
XXX.YYY.ZZZ.160
How do I can SSH from 192.168.1.106
(my home) to 192.168.10.130
(office) or vice versa? Is this possible? Please help me.
This is possible if you have port forwarding on a receiving router. For instance, if you want to ssh from office back to home, you need to go into home router settings first, and set up port forwarding for port 22 to a specific IP address on your home network and port number, in your case 192.168.1.106
port 22
. That way if you do from office ssh [email protected]
, you will be redirected from router to your home computer.
Settings for port forwarding differ form router to router; just to get a feel for it, look at the examples in the How To Forward Ports on Your Router article
With office, it may be difficult because it depends on your company and typically IT would say no, but you might want to ask them
You need a public facing port to connect to.
A good solution is NGROK , search "TCP tunnel"
you want ngrok tcp 22
.
It exposes the port to its own temporary domain name that is public facing.
ngrok
is free, though the free users have their domain reset when ngrok
closes. Putting the computer to sleep doesn't close down ngrok
. Just don't close down ngrok
and you should be fine.
The other option I have done is to buy a host, (domain optional) (I use digitalocean, and namesilo), then use tinc to vpn my home computer, my server, and my laptop with my server as the host and the other two computers as clients. I then ssh
to my server, then I can ssh
to my other computer.
Use port forwarding on your router configuring for sample all entering traffic through ports 20 to 29 be redirected to the internal IP address with the same ports.
Additionally to this you may consider an external dynamic DNS service such as dyn.com (formerly dyndns.com) or noip.com.