Kali linux ssh доступ

Kali linux ssh доступ

Since our release of Kali Linux 2022.1 it is possible to easily configure the SSH client for wider compatibility to allow Kali to talk to as many SSH servers as possible. In wide compatibility mode, legacy key exchange algorithms (such as diffie-hellman-*-sha1) and old ciphers (such as CBC) are enabled. As a result, tools used inside of Kali are able to communicate using these outdated methods. This is done to help increase Kali’s ability to talk to older, obsolete SSH servers that are still using these older protocols. Older services using this may be at end of life, thus increasing the chances of discovering vulnerabilities or other problems.

Note that this is not the default. Out of the box, the SSH client in Kali Linux is configured for Strong Security to enforce communication over more secure channels.

This setting can be changed easily using the kali-tweaks tool. Simply:

  • Open a terminal and run kali-tweaks .
  • From there, select the Hardening menu.
  • Now you can choose between Strong Security(the default) and Wide Compatibility.

Note: This is achieved by creating or deleting the configuration file /etc/ssh/ssh_config.d/kali-wide-compat.conf .

SSH server: automatic host keys generation

Since the release of Kali Linux 2022.1, the SSH host keys are automatically generated if missing. This is achieved via the systemd service regenerate-ssh-host-keys .

So what are SSH host keys exactly? Those keys are required for the SSH server to be functional. They are supposed to be unique for each machine. Those keys can be found under /etc/ssh and are named ssh_host_*_key . This is how it usually looks like:

[email protected]:~$ ls -l /etc/ssh/ssh_host_* -rw------- 1 root root 1373 Feb 3 23:50 /etc/ssh/ssh_host_dsa_key -rw-r--r-- 1 root root 599 Feb 3 23:50 /etc/ssh/ssh_host_dsa_key.pub -rw------- 1 root root 505 Feb 3 23:50 /etc/ssh/ssh_host_ecdsa_key -rw-r--r-- 1 root root 171 Feb 3 23:50 /etc/ssh/ssh_host_ecdsa_key.pub -rw------- 1 root root 399 Feb 3 23:50 /etc/ssh/ssh_host_ed25519_key -rw-r--r-- 1 root root 91 Feb 3 23:50 /etc/ssh/ssh_host_ed25519_key.pub -rw------- 1 root root 2590 Feb 3 23:50 /etc/ssh/ssh_host_rsa_key -rw-r--r-- 1 root root 563 Feb 3 23:50 /etc/ssh/ssh_host_rsa_key.pub 

Since these keys must be unique for each machine, they can’t be embedded in pre-built Kali images such as the Kali Linux VM images or the ARM images. It’s usually up to the user to create those keys before running the SSH server for the first time. However, for most users who are not familiar with SSH, this is a hurdle, as they are not aware of this technical detail.

To make it easier, Kali Linux now comes with a systemd service that takes care of that automatically, and generate those keys if they are missing. In theory, it’s only during a first boot of a pre-built image that the service kicks in. On subsequent boots, the keys already exist and therefore nothing happens. This may not be the case for users who may remove these keys themselves.

Читайте также:  Linux upload file to http

For those who are not comfortable with this automatic behavior, it’s very simple and straightforward to disable it:

[email protected]:~$ sudo systemctl disable regenerate-ssh-host-keys.service 

Updated on: 2023-Mar-06
Author: arnaudr

Источник

How to Enable SSH in Kali Linux

In the mid-90s, telnet spawned a secure successor called the secure shell. This is a protocol to communicate with other computers. There are other protocols where you can log in and perform functions as performed by SSH, but it is not safe because it is not encrypted, so people can hijack your sessions and data. However, SSH encrypts the data through a tunnel so that you can securely log in to a remote machine, transmit files, or safely issue remote commands. SSH is applied in the client-server model to transfer and receive the files. There are two terms involved, here: the SSH server and the SSH client. One system acts as a server and the other acts as a client. A public key and a private key is locally stored on the SSH server and client, respectively. The SSH client will make contact with the SSH server and provide the ID of the key pair it wants to use to prove its identity. The challenge is created by the SSH server, which is encrypted by the public key and sent to the client. The client receives the challenge, decrypts it with the private key, and the original challenge is sent back to the SSH server. After the consultation, a secure connection is established. SSH protocol was invented to replace the tunnel so that you could identify the server you are connected to.

We will now take a look at how to enable SSH in Kali Linux.

Install Kali Linux remote SSH-OpenSSH server

Usually, Kali Linux has an OpenSSH server running on it or installed on it. Once you start this server, you can log in via SSH. So, you do not have to install the server, but if you do find yourself in a situation where you do not have it, then you can follow this simple command to install and enable the remote SSH open server in Kali Linux.

Note: Enabling the SSH server is quite risky, as anyone who knows your password can break into your machine. Securing your password should be your first priority. If you want your service to run for the whole time, then you may follow the next step.

Enable Kali Linux Remote SSH Service

First, you must remove the run levels by entering the following command.

The next step is to load SSH defaults.

After loading, next, you will check whether the service is running.

If you want to see a lot more, then you can install chkconfig, which can be installed by entering the following command code.

Читайте также:  Установить владельца файла linux

You can run chkconfig by entering the command given below.

Change Kali Default SSH Keys to Avoid MITM Attack

Every Kali Linux system installed has a chance of a MITM (Man In The Middle) attack. MITM attacks are usually observed in a client-server environment. A MITM attack occurs when a hacker gets in between these two components. Hackers can take advantage of unencrypted communication through the MITM attack and can listen in on all of your traffic. To avoid MITM attacks, you can follow the below procedure.

The first step is to move Kali SSH keys to a new folder.

The second step is to regenerate the keys by entering the following command.

]

The third step is to verify that the SSH key hashes are different. Enter the following command for verification.

Finally, enter the following command code to restart the SSH.

Set MOTD with a Nice ASCII

MOTD (Message of the Day) is used to send a common message to all the users. The banner is usually boring, so you can edit the files and add the text of your choice, then save the file.

Troubleshooting

By changing SSH keys in the middle, you may experience a warning sign. Enter the following command to fix this problem.

Delete the line that is causing the troubleshoot and restart the SSH.

Change SSH Server Port for Safety

The port number can be changed by entering the following command.

The SSH_config file can be edited further by entering the following command.

Now, you can restart the OpenSSH server

Use the SSH for the next time you use it.

Here, 10101 is the destination port, p stands for port, and the hostname can be IP or FQDN.

Conclusion

The term ‘SSH’ describes a set of rules and guidelines that tells your computer how to send data from one place to the other. The administrators, such as the application owner, administrators responsible for the entire system, or privileged users with higher levels of access mainly use the SSH server. I hope this article helped you with enabling SSH in Kali Linux.

About the author

Younis Said

I am a freelancing software project developer, a software engineering graduate and a content writer. I love working with Linux and open-source software.

Источник

Как включить SSH в Kali Linux

Если вы хотите включить SSH в Kali Linux, в этой статье вы узнаете, как это сделать.

SSH

В середине 90-х годов telnet породил безопасного преемника под названием secure shell. Это протокол для общения с другими компьютерами. Существуют и другие протоколы, в которых можно входить в систему и выполнять функции, выполняемые SSH, но они небезопасны, поскольку не зашифрованы, поэтому люди могут перехватить ваши сеансы и данные. Однако SSH шифрует данные через туннель, чтобы вы могли безопасно войти в систему на удаленной машине, передавать файлы или безопасно отдавать удаленные команды. SSH применяется в модели клиент-сервер для передачи и получения файлов. Здесь используются два термина: SSH-сервер и SSH-клиент. Одна система выступает в роли сервера, а другая — в роли клиента. Открытый ключ и закрытый ключ хранятся локально на сервере и клиенте SSH соответственно. Клиент SSH связывается с сервером SSH и предоставляет идентификатор пары ключей, которую он хочет использовать для подтверждения своей личности. Сервер SSH создает вызов, который шифруется открытым ключом и отправляется клиенту. Клиент получает вызов, расшифровывает его с помощью закрытого ключа, а исходный вызов отправляет обратно на SSH-сервер. После консультации устанавливается защищенное соединение. Протокол SSH был изобретен для замены туннеля, чтобы можно было идентифицировать сервер, к которому вы подключены.

Читайте также:  Этапы загрузки системы linux

Сейчас мы рассмотрим, как включить SSH в Kali Linux.

Установка сервера SSH-OpenSSH в Kali Linux

Обычно в Kali Linux запущен или установлен сервер OpenSSH. Запустив этот сервер, вы сможете войти в систему через SSH. Таким образом, вам не обязательно устанавливать сервер, но если вы оказались в ситуации, когда у вас его нет, то вы можете выполнить эту простую команду для установки и включения SSH сервера в Kali Linux.

Установка сервера SSH-OpenSSH в Kali Linux

Запустите SSH сервер следующей командой

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

Включение службы Kali Linux SSH

Включение автозапуска службы

sudo systemctl enable ssh

sudo systemctl enable ssh

Изменение ключей SSH по умолчанию в Kali для предотвращения атак MITM

Каждая установленная система Kali Linux имеет шанс подвергнуться атаке MITM (Man In The Middle). Атаки MITM обычно наблюдаются в среде клиент-сервер. Атака MITM происходит, когда хакер проникает между этими двумя компонентами. Хакеры могут воспользоваться преимуществами незашифрованной связи посредством атаки MITM и прослушивать весь ваш трафик. Чтобы избежать атак MITM, вы можете следовать приведенной ниже процедуре.

Первым шагом будет перемещение ключей Kali SSH в новую папку.

Создадим директорию для хранение старых ключей

sudo mkdir default_kali_keys

и переместим текущие ключи

sudo mv ssh_host_* default_kali_keys/

Вторым шагом будет регенерация ключей путем ввода следующей команды.

sudo dpkg-reconfigure openssh-server

sudo dpkg-reconfigure openssh-server

Третий шаг — проверка того, что хэши ключей SSH отличаются. Введите следующую команду для проверки.

md5sum ssh_host_*

md5sum default_kali_keys/*

Наконец, введите следующий командный код для перезапуска SSH.

Установите MOTD с помощью красивого ASCII

MOTD (Message of the Day) используется для отправки общего сообщения всем пользователям. Баннер обычно скучный, поэтому вы можете отредактировать файлы и добавить текст по своему выбору, а затем сохранить файл.

MOTD

Устранение неполадок

При смене ключей SSH в середине может появиться предупреждающий знак. Введите следующую команду, чтобы устранить эту проблему.

sudo nano /root/.ssh/known_hosts

Удалите строку, вызывающую неполадки, и перезапустите SSH.

Изменение порта сервера SSH для обеспечения безопасности

Номер порта можно изменить, введя следующую команду.

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config_backup

Файл SSH_config можно редактировать и дальше, введя следующую команду.

sudo nano /etc/ssh/sshd_config

/etc/ssh/sshd_config

Теперь вы можете перезапустить сервер OpenSSH

теперь можете подключиться к своей машине Kali Linux по SSH

Здесь 10101 — это порт назначения, p означает порт, а host может быть IP или FQDN.

Заключение

Термин «SSH» описывает набор правил и рекомендаций, который говорит вашему компьютеру, как пересылать данные из одного места в другое. Администраторы, такие как владелец приложения, администраторы, отвечающие за всю систему, или привилегированные пользователи с более высоким уровнем доступа в основном используют SSH-сервер. Надеюсь, эта статья помогла вам с включением SSH в Kali Linux.

Похожие записи:

Источник

Оцените статью
Adblock
detector