2

I installed on my Ubuntu 16.04 the openssh-server and wanted to access my pc remotely through the terminal of other networks, such as the university, for example, but I'm only able to access through ssh when on the same network.

If someone can help me establish this external connection so I can access my pc while on another connection I would be very grateful.

I do not use a router, other than the one provided by Vivo (Router / mode Vivo Fibra).

enter image description here

NOTE: I do not intend to use putty, Team Viewer or anything, I just want to use the terminal, for me it's more practical.

I do not have fluence on English, sorry for this. Text translated by google.

user68186
  • 33,360
  • Welcome to Ask Ubuntu. This is a networking problem, not Ubuntu problem. You have to setup port forwarding in the router (Vivo Fibra). We don't know how to do that. – user68186 Sep 04 '18 at 20:57
  • This is the page of port forwarding on the router [https://i.imgur.com/yiX9hKt.png], but I dont know where I need to put the IP of my machine/router and the protocol that I need to use – Gustavo Luiz Bispo dos Santos Sep 04 '18 at 21:11

1 Answers1

1

Port forwarding

Settings

  • Rule name: SSH for my computer (you can put any meaningful text)
  • Protocol: TCP (this is the most common protocol used by SSH)
  • External port: 2222 (you can use almost any port, but this is the most common)
  • Internal port: 22 (this is the port used by the SSH service on your computer)
  • External IP: 0.0.0.0 or leave it blank if allowed (the router will allow connections from any IP)
  • Internal IP: your computer's private IP, probably will look like 192.168.1.X.

Note: in order to have a static (always the same) private IP for your computer, you may need to tweak additional settings on the router (search static DHCP allocation or reservation for more information).

Explanation

This configuration will mean that any connection from the outside world to your router's public IP address (which you can see visiting this page) on the port 2222 will be redirected to the port 22 of your computer (private IP address).

To connect via SSH to your computer, you'll need to specify the port, because it isn't the default one (22) but a custom one (2222 in the example). You can run the example below to connect from the outside world:

ssh user@public.ip.address -p 2222

Related

Alternatives

tmate is a command line tool to connect computers behind a firewall using SSH.

0x2b3bfa0
  • 8,780
  • 6
  • 36
  • 55
  • I have made what you have said, but now I have this message on the terminal ssh: connect to host 191.35.xxx.xx port 2222: Connection refused – Gustavo Luiz Bispo dos Santos Sep 04 '18 at 22:04
  • @GustavoLuizBispodosSantos: then you've (probably) done something wrong. Can you post anterior screenshot of the lower part of the page? – 0x2b3bfa0 Sep 04 '18 at 22:10
  • This is the result after mading what you have said [https://imgur.com/a/2wdwKd8] – Gustavo Luiz Bispo dos Santos Sep 04 '18 at 22:15
  • @GustavoLuizBispodosSantos: I meant the lower part of the web page, where says "forwarding table" – 0x2b3bfa0 Sep 04 '18 at 22:24
  • It is complete, It just have 3 rules – Gustavo Luiz Bispo dos Santos Sep 04 '18 at 22:26
  • Well, I can access from Spain. Please try again connecting. (Sorry if I was so nosey) – 0x2b3bfa0 Sep 04 '18 at 22:31
  • Maybe your problem is that you're trying to access to the forwarded port from the same internet connection. – 0x2b3bfa0 Sep 04 '18 at 22:34
  • now I dont know what IP I need to use to connect outside my network. curl ipconfig.io gives me 242.158.x.xx and curl ifconfig.me gives me 191.35.xxx.xx what of these just I need to use. NOTE: I am still having Conection refused error with 191.35.xxx.xx and with 242.158.x.xx nothing happens, and I need to use ^C to exit – Gustavo Luiz Bispo dos Santos Sep 04 '18 at 22:37
  • I can connect perfectly from my computer, so your port forwarding works. Can you try connecting from another network and another computer (i.e. your smartphone's 3G/4G connection)? – 0x2b3bfa0 Sep 04 '18 at 22:46
  • I'm going to sleep now because on my timezone (CEST) is [past] bed time (00:49). If you did solve the problem, please mark the answer as accepted (grey tick on the left) and (optionally upvote it). If you keep having issues, leave a comment and I'll read it tomorrow. Please check this recording: http://asciinema.org/a/zMSC3TEQgJxoTVoQepcev7svL the good one is the 191.35.x.x – 0x2b3bfa0 Sep 04 '18 at 22:50
  • Ty, I am trying to adquire a 4G connection to test it, If it works I will mark the answer – Gustavo Luiz Bispo dos Santos Sep 04 '18 at 22:58