I am connected to WiFi router in my home and would like to connect to another machine connected to another WiFI router. The WiFi routers have public IP Address.

I want to ssh into the machine rather than connecting via TeamViewer/AnyDesk. I tried using ngrok but it does not allows me ssh connect to the machine.

Is there any GitHub repo which serves this purpose?

closed as too broad by Kusalananda, Thomas Dickey, Sparhawk, G-Man, Jesse_b Mar 3 '18 at 12:48

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    ... and these two machines are running some kind of Unix? Are there SSH services running on them? Does the router for the target machine redirect incoming SSH connections to that machine? – Kusalananda Mar 2 '18 at 13:33
  • You can use tor hidden services if portforwarding is not available: nurdletech.com/linux-notes/ssh/hidden-service.html – Ipor Sircer Mar 2 '18 at 13:46
  • 1
    This is a very generic question. Is the target host setup with SSH (or some other service you are trying to connect to)? Is the firewall on the host allowing traffic into that service? Is the router in the target network correctly NATting traffic onto the service? – Pedro Mar 2 '18 at 14:49

I'm going to suppose that you have the ssh client and server running in the machines , so your problem is not there.

Because you don't give so much information, I'm also going to suppose that your problem is a network configuration problem (as daniel-marchall suggested in his comment) and not a software problem:

Usually, the wifi routers work with two different networks, one is the network with your public ip, and the other is a network with private ips, where all your devices are connected (it depends on your company, but usually these ips are something like 192.168.x.y, or 10.0.x.y)

When your computer wants to connect to an external site (i.e., to an ip that not belongs to your private network), your router 'transfers' your packets from the private network to the public network, but changing the packets slightly (basically, it changes your private ip with its public ip). Doing that, allows an external site to sent the packets back to your router.

When your router receives a packet through its public interface, it determines where it should go this packet based in some internal data and metrics (look for NAT if you want for info), and it transfers the packet from the public interface to your private network (again, changing some details of the packet like the destination ip).

What you want to do is to connect to the public interface of the router (through ssh to the public ip), and then, the router should transfer the packets to your machine. The problem is that in this case, you need to help the router with the transfer, because it hasn't enough information about what to do with the ssh package.

For doing that, the easiest way is with port forwarding (again, as daniel-marchall before). That means that you should enter into the configuration of your router, and configure it saying "hey, all packets that arrives to your public interface at port number 22, you should transfer them to my private ip".

The configuration process depends on the model of your router. Look for it on google, because there are tons of manuals over there.

Other problems that you can have is that you cannot modify the router configuration (and maybe with an inverse tunnel you could do it), or thousand of other different problems, but we need more information for helping you.

Not the answer you're looking for? Browse other questions tagged or ask your own question.