Входящие соединения с публичного на приватный IP-адрес

395
user3152810

Сегодня я проверил auth.log моей малины (частный IP-адрес в моей домашней сети за wrt54gl). Удивительно, но я увидел много строк "Failed password for root from".

IP-адрес SRC можно найти в списках злоумышленников, использующих грубую силу SSH.

Когда я подключаюсь к своей RasPberry через Интернет, я обычно устанавливаю ssh-соединение с публичным IP-адресом моего маршрутизатора и подключаюсь к частному адресу RasPberry.

Так как же кто-то может подключиться напрямую к этому устройству, которое имеет только частный адрес?

eth0 Link encap:Ethernet Hardware Adresse b8:27:eb:e5:7a:5b inet Adresse:192.168.0.5 Bcast:192.168.0.255 Maske:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1 RX packets:2774178 errors:0 dropped:933 overruns:0 frame:0 TX packets:5544091 errors:0 dropped:0 overruns:0 carrier:0 Kollisionen:0 Sendewarteschlangenl▒nge:1000 RX bytes:457172801 (435.9 MiB) TX bytes:875979564 (835.3 MiB)  lo Link encap:Lokale Schleife inet Adresse:127.0.0.1 Maske:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metrik:1 RX packets:2695 errors:0 dropped:0 overruns:0 frame:0 TX packets:2695 errors:0 dropped:0 overruns:0 carrier:0 Kollisionen:0 Sendewarteschlangenl▒nge:0 RX bytes:725188 (708.1 KiB) TX bytes:725188 (708.1 KiB)   Jun 15 13:42:12 rpi sshd[15608]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=116.31.116.31 user=root 
1

1 ответ на вопрос

2
stueja

The same way you do it, assuming you use port forwarding. If you try to login to your raspberry from remote, maybe even with a false password, you should see a very similar line in auth.log.

Of course, you will connect to your public IP address which is assigned to the external interface of the router. I assume that you established port forwarding in the router, so that any connect to a specific port on your public IP address will be forwarded to the raspberry. In this specific case, I assume you forwarded port 22 in the router to be forwarded to port 22 of your raspberry.

The way the guy behind the other IP address went is the same and probably like

  • scanning the internet for hosts which have ports open
  • running a tool which
    • connects to that host and port
    • tries to login with password lists

Or maybe he does it manually and fires up his ssh client, connects to your public IP address, port 22, which will be forwarded to the raspberry, and simply tries common username/password combinations (pi/raspberry, root/root, ...).

To avoid that you can

  • configure sshd to use private/public key authentication, not password authentication
  • tell your router to forward a different port (e. g. 2222) to port 22 of the raspberry. Be sure to adjust your (remote) ssh client so that you can still connect.
  • install knockd and knock the port open before you want to use it
  • install fail2ban to block unauthorized IP addresses

(for a little more detailed overview of the mentioned methods please also see here.)

Или, если вы всегда туннелируете через маршрутизатор, отключите переадресацию портов на Raspberry Pi :) NIZ 7 лет назад 0
Вы абсолютно правы! Была переадресация портов, которую я не использовал в течение некоторого времени и забыл об этом, потому что я всегда туннелирую. Виноват. Спасибо за хорошее объяснение. user3152810 7 лет назад 0
Добро пожаловать. stueja 7 лет назад 0