A
A
Alexander Dedunovich2021-03-10 15:25:22
linux
Alexander Dedunovich, 2021-03-10 15:25:22

How to connect via SSH to a server with a dynamic IP?

Good afternoon!
I have a laptop at home , Internet access - wifi
I would like to have constant access to it via SSH outside the local network

Please tell me how can this be done ?

I don’t know if this is important, but here is the additional data: Laptop
OS - Ubuntu Server
Router - Keenetic 4g
Provider - MTS (Belarus)

PS I did not find how to solve this problem adequately, so I wrote a crutch: my bot in telegram, which is still gives access to the command line, but there are no nice things like taboo completion and file transfer.

UPD:
I want to do everything for free: no white IP, no paid services, etc. :)

Answer the question

In order to leave comments, you need to log in

8 answer(s)
S
Sanes, 2021-03-10
@Sanes

VPN

P
pfg21, 2021-03-10
@pfg21

Dynamic DNS
home through free hldns.ru get the name by the
way MTS c Belarus at one time was heavily drowned for promoting ipv6. check if ipv6 works

R
rPman, 2021-03-10
@rPman

There are different forms of the absence of a white ip
For example, a dynamic ip address is when the ip address is issued but for a certain period of time (hours-day-session) and then changes - in this case, it is enough to configure the provider's dyndns (there are a huge number of them, from free to options for paid dns / hosting providers), you locally configure some kind of application (routers can also work with some dyndns providers) that determines your current ip address and sends it to the provider, and he sets up a domain name for you to the current ip address, then open it with the usual settings of the router ports of your local server and connect via dyndns domain name.
If you are behind NAT, i.e. even your router receives an address from the local network to access the Internet (I saw this with mobile providers), then yes, this is a sentence. Here the options are only vpn or, for example, reverse ssh port forwarding:

On your laptop, an automatic ssh connection to a remote server with a white ip is configured, with port forwarding of your already local ssh server to that remote one. In this case, to connect, you just need to connect to a remote server and the connection will be redirected. Development of options - you can not make the remote port available from the Internet, and to connect via ssh you will first need to connect to the ssh of that server, also with port forwarding configured, and even then connect to your server.

M
Maxim Grishin, 2021-03-10
@vesper-bot

Ask the provider for a white IP address, forward it on the router, where the Wi-Fi is, port 22 to the laptop and go. At the same time, be prepared for the fact that not only you will try to break into it, and take care of protection (fail2ban for example).
And for free - in fact, a VPN to a free VM somewhere in the clouds and configure proxying or double entry there.

Z
Zzzz9, 2021-03-10
@Zzzz9

If effortlessly your choice hamachi-pc.ru

A
Alexey Kopendakov, 2021-03-11
@alex_kag

If this is mobile Internet (I don’t know about the stationary one from mts), then mts has a white ip service, it costs about 3 rubles or something. When connecting the service, it will be possible to connect from the outside to the modem. The IP will then be dynamic. But at the same time, dindns will work

R
Rozello, 2021-03-11
@Rozello

I see two more or less simple options.
VPN (for example Hamachi or similar) - this will allow you to bypass NAT if necessary and the address will be static.
Tor\I2P - in fact, the method is similar to the previous one and will solve similar problems (you can get a domain name for free inside the tor\2ip network and forward access to ssh inside this network).
If you look at more complicated options, then first you need to understand what restrictions your Internet provider has specifically.
If the address is white, but dynamic, and the laptop itself is behind the router's nat, then:
1. Forward the port on the router
2. Screw dyndns
If the address is white, but static, and the laptop itself is behind the router's nat, then:
1. Forward the port on the router
If the address for NAT provider - then:
The easiest way is to use the first two options (vpn\tor\i2p).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question