ssh (remote console) between 2 computers from different private networks

5,186

Private networks are bad for exactly these kind of problems: Both cannot be easily accessed from outside the network, and because the other computer is always outside the network a direct connection is not possible.

Maybe the easiest way is to set up IPv6 on both computers. This will give both computers a real IP-Address and they are therefore reachable from each other.

The other way would be setting up some port forwarding on the second router. then you can connect from the first computer to that port of the second router which forwards it to the second computer.

The last way would involve nasty tunneling. In this case you need some public reachable host to which you can ssh from both computers to set up some indirect connection similar to what your teamviewer is doing.

Share:
5,186

Related videos on Youtube

Loom
Author by

Loom

Updated on September 18, 2022

Comments

  • Loom
    Loom over 1 year

    I have two computers. Both of them are from different private networks. I'd like to connect from one of them to another (to program on it remotely). I attempted to use some remote desktop software (teamviewer). However, I encountered some issues with internet connection bandwidth and screen resolution. So, I search some way to get just terminal access to remote computer. I'm a beginner in Linux. And as far as I understand the remote console access to other computer is obtaining via ssh (or telnet?). Unfortunately both of computers have private IP, so I unable to use SSH (reverse) tunneling.

    How to get remote terminal access to other computer in my case? (I'd prefer free solution)

    • phemmer
      phemmer over 10 years
      You question implies that you were able to connect with "teamviewer", but had issues with it. How did you get that to work around the private IP issue?
    • Loom
      Loom over 10 years
      @Patrick - When one started teamviewer application, this application connects to some teamviewer server. Each computer has some kind of numeric ID. So, if I want to connect to another computer, I enter in my teamviewer application ID of a remote computer teamviewer client application. So, connect established over Teamviewer servers. I hope, there is some similar solution for terminal access exists.
    • michas
      michas over 10 years
      Each of your two computers is behind a different NAT, i.e. both can access the internet but cannot be reached from the internet?
    • Loom
      Loom over 10 years
      @michas - Yes, each of them behind different NATs
    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' over 10 years
      If neither computer can see the other one, then you need a third machine that's visible to both. For the Teamviewer protocol, you were using Teamviewer's services. SSH is easy to set up if you can find a machine with a public IP address where you can run an SSH server.
    • Loom
      Loom over 10 years
      @Gilles - Thank you. Do you know, it there exists some similar service for access to terminal of a remote computer? And if there isn't such services, how do I obtain third machine. Is there some hosting service or something like this to obtain such machine?
  • Loom
    Loom over 10 years
    Thank you. However, I'm not good at networks and do not understood clearly. Is it possible to set up IPv6 to my computers? These computers are just simple ubuntu desktops. I do not have access to routers. Looks like just tunneling can help me. Am I right?
  • michas
    michas over 10 years
    Yes, linux supports IPv6 since 1996. On ubuntu it is enabled by default. (Typing ifconfig you should already see some IPv6 addresses.) How easy it is to connect to the outside mainly depends on your internet provider. - Some providers provide native IPv6, and you need to do nothing at all. For others you need to manually set up a tunnel. A nice tool for that might be aiccu. Most newer routers are able to provide IPv6 for the whole network. But this again requires access to the router.
  • Loom
    Loom over 10 years
    Thank you. Yes, there is IPv6 address in ifconfig output. I tried to test my IPv6 with test-ipv6.com And it responsed: No IPv6 address detected. So, I need aiccu to get my IPv6 address visible from internet. If I understand you correctly?
  • michas
    michas over 10 years
    Yes, without support from your ISP and without access to your router - the best way is probably to set up your own tunnel to the IPv6 world. aiccu is easy to use. You need to register at sixxs, create a tunnel for each of your computers and enter the credentials at the aiccu client.