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).

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.

2
  • This is the page of port forwarding on the router [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 Commented Sep 4, 2018 at 21:11
  • Welcome to Superuser! Instead of doing it as a comment, it is usually better to edit your question when adding information Commented Sep 4, 2018 at 22:56

2 Answers 2

0

You have to find the external ip address, you can do that with https://www.whatismyip.com/ ....

You have to setup your ssh server, mainly your port.... set your port in /etc/ssh/sshd_config to something other than 22......then do

service ssh restart....

You have to have a username to use in the ssh command that you have permission to log into.....

You have to allow ssh in your iptables......like this:

iptables -I INPUT 1 -p tcp --dport PORT -j ACCEPT.....

-----------------------------------------------------------------------------

EDIT:

Do this↓↓↓↓↓↓↓↓↓ to add new port for ssh remember PORT in the command should be the port that you choose as maybe 34503

root@ubuntu:/# iptables -A INPUT -p tcp --dport PORT --jump ACCEPT
root@ubuntu:/# iptables-save

end of edit

-----------------------------------------------------------------------------

You have to be sure there is open through your router..... portforwarding the service ssh for the port you've chosen.....

You can also set ssh keys like here......https://www.debian.org/devel/passwordlessssh.......

then there is the command itself:

ssh -p PORT USER@EXTERNAL-IP

when you connect answer yes to the question if you trust the new connection..... and your all set, good luck

9
  • How can I allow this iptables -I INPUT 1 -p tcp --dport PORT -j ACCEPT Commented Sep 4, 2018 at 22:16
  • why make things harder throuh changing port? makes things little bit more complicated and wont add any security Commented Sep 4, 2018 at 22:20
  • @Gustavo if you can access ssh from another PC in same network it means that you do not need to use iptables. However, if you already changed port and restarted sshd then it is possible that new port is closed. I'd say do not change ssh port. Commented Sep 4, 2018 at 22:26
  • I can access from other PC on the same network, but I need to access outside this network Commented Sep 4, 2018 at 22:28
  • @GustavoLuizBispodosSantos I've updated my answer good luck Commented Sep 4, 2018 at 22:32
1

If you want to access a public IP address then you need to know the public IP address, which is dynamic. If your PC is on the same domain as your Ubuntu server, then you can use the domain name instead of the IP address. Ex:

ssh [email protected]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .