This answer is based on the accepted one, but adding the details that allowed me to get it done. I apologize for the pedestrian explanation, since this is not at all of my expertise.
Suppose you have two computers, A
and B
. You want to ssh
from A
to B
, and you cannot do any port forwarding in the routers connected to them.
As the accepted answer states, you need a server S
to do this: in computer B
, you will allow ssh
connections coming from S
; and from computer A
, you will access that tunnel at S
to reach B
.
But how do you get that server S
? I found serveo
(link: https://serveo.net/). It is of very simple use. You do not have to install anything or register and it is free. According to the website, the steps to follow are:
Think of an alias for computer B
. For example, computer_B_alias
.
In computer B
, execute ssh -R computer_B_alias:22:localhost:22 serveo.net
.
Now, you can access computer B
from computer A
by executing the following in computer A
: ssh -J serveo.net user@computer_B_alias
, where you have to substitute user
by the name of the user in computer B
.
P.S.: Of course, you make point 2 an automatic task when starting your computer B
.
P.S.S.: Before you try this, make sure that ssh
is installed in both computers. For Ubuntu, sudo apt-get install ssh
would do the job.