Warning remote host identification has changed как исправить

The "Warning: Remote host identification has changed" error protects your connection from certain malicious attacks. Here's how to fix it.

A secure internet connection is not just the ideal — it’s essential. In fact, we’re going to go as far as saying it’s the number one priority for your website. The “Warning: Remote host identification has changed” error protects your connection from certain malicious attacks, although in some cases, you can inadvertently cause the error too.

The error is related to your Secure Shell (SSH) keys and the server “fingerprint” a client will check for. If Secure Shell thinks there’s an issue, it will block access to your server and throw an error. But you can fix this in a few steps.

Over the next few minutes, we’re going to show you how to fix the “Warning: Remote host identification has changed” error for both Windows and Mac. First, though, let’s give you some more details on the error message itself.

A secure internet connection is not just the ideal — it’s essential 💪 While it may be annoying, this error protects your connection from attacks. 🙅‍♀️ Learn more ⬇️Click to Tweet

What the “Warning: Remote Host Identification Has Changed” Error Is

One of the most secure ways to connect to a web server is to use SSH. It’s a command-line tool that lets you access an insecure network securely. Consider it like a “super-SFTP” type of setup, although it’s not a 1:1 comparison in practice.

You can access your site from almost anywhere you can use the internet, as long as you have the right login credentials. What’s more, most macOS and Linux machines have an SSH client built into the Operating System (OS). For Windows, you’ll use a dedicated interface (and we’ll talk about this in more detail later).

As for the “Warning: Remote host identification has changed” error, it relates to the security checks your client will do. An SSH connection uses dedicated “keys” — small files stored on your computer — as authentication. It’s sort of like a Secure Sockets Layers (SSL) handshake, and in fact, there are some high-level similarities between SSH and SSL.

One aspect the keys help with is to provide a permanent fingerprint of its host server. This will make sure the connection is accurate and that you’re not subject to a “machine-in-the-middle” attack.

If the client thinks those fingerprints differ from what it understands to be correct, you’ll get the “Warning: Remote host identification has changed” error at the point of login:

[[email protected] ~]$ ssh [email protected]

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

Someone could be eavesdropping on you right now (man-in-the-middle attack)!

It is also possible that a host key has just been changed.

The fingerprint for the RSA key sent by the remote host is

xx:xx:xx.

Please contact your system administrator.

Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message.

Offending RSA key in /var/lib/sss/pubconf/known_hosts:4

RSA host key for user has changed and you have requested strict checking.

Host key verification failed.

As errors go, this is detailed and clear — it tells you what’s happened, a potential reason for why, and how you might fix it.

However, there’s one aspect we can touch on a little further before showing you how to fix the “Warning: Remote host identification has changed” error.

How the known_hosts File Helps SSH Authentication

You’ll notice that the error message references a known_hosts file. The name should give you a clue as to what it contains, but for clarity, it’s a list of SSH remote hosts known to the computer. It’s used as a reference client file for the authentication process.

When you first connect to a server, you’ll often get a confirmation request through your interface, asking whether you want to connect. If so, this fingerprint will become part of your known_hosts file.

Of course, if the fingerprint differs from what is in the known_hosts file, this could indicate a malicious user is targeting you. In other cases, you may already know why there’s a difference, although it pays to be vigilant regardless.

How To Fix the “Warning: Remote Host Identification Has Changed” Error (on Windows and Mac)

You can work to fix the “Warning: Remote host identification has changed” error for both Windows and macOS. However, you have more flexibility for doing so on Mac.

We’ll cover lots of the ways you can make things right again, starting with Windows.

1. Windows

It’s important to note that Windows machines might not have a known_hosts file. However, if you use the OpenSSH client, there is a file. To find it, open the Windows search bar, and navigate to your user folder with the %USERPROFILE% command.

This will open the directory within the File Explorer. There will also be a .ssh folder within:

The Windows File Explorer.

The Windows File Explorer.

The file we want in this folder is known_hosts. You can open this with Notepad (or your favorite text editor). Inside will be a list of keys:

The Windows known_hosts file.

The Windows known_hosts file.

Here, you can delete the key that’s causing the problem, then resave the file.

Some users may prefer the PuTTY client. The keys sit in the Registry, although they perform the same purpose as OpenSSH.

You’ll want to open the Windows Registry Editor (otherwise known as “regedit”). You can do this in whatever way you’re comfortable, but the quickest way is to type the app’s name into Window’s search bar:

The Registry Editor link in the Windows Start menu.

The Registry Editor link in the Windows Start menu.

Here, look for the following destination within regedit:

HKEY_CURRENT_USER/Software/SimonTatham/PuTTY/SshHostKeys/

You’ll see a list of entries here relating to the saved connections on your computer. Your job is to delete whichever one is causing an issue:

Deleting a Registry key in regedit.

Deleting a Registry key in regedit.

Once you click on the Delete button, you’ll also need to confirm that you want to remove the key:

The Confirm Value Delete dialog.

The Confirm Value Delete dialog.

Clicking Yes here means the key will be gone for good, and you shouldn’t get the “Warning: Remote host identification has changed” error any longer.

2. Mac

The Mac has a couple of ways to fix the “Warning: Remote host identification has changed” error — either through a premium app such as SSH Config Editor or the Terminal. The results will be the same, so we advise you to choose whichever option is more comfortable (and budget-friendly).

Our preferred approach is to access the file within a Terminal window (or iTerm2 if you use that app), and also open it with a dedicated Nano or Vim editor. This is because it’s accessible to everyone and straightforward to use regardless of your experience level.

Here, we’re going to use Nano. First, open your Terminal using whatever process is most comfortable:

Opening the Terminal from Spotlight.

Opening the Terminal from Spotlight.

From here, run the nano ~/.ssh/known_hosts command in your window. This will open a new Nano instance and display the keys within your known_hosts file:

The Nano editor with the known_hosts file open.

The Nano editor with the known_hosts file open.

You should delete the key causing the “Warning: Remote host identification has changed” error, then save your changes.

You might also want to delete the entire known_hosts file, especially if you only use SSH for one or two sites. To do this, you can run rm .ssh/known_hosts in a Terminal window.

There’s one more method to alter the known_hosts file on Mac: using the ssh-keygen utility from the command line. This is great if you don’t want to dig into the file itself, or if you want to work with only one site or key.

To achieve this, open a Terminal window and run ssh-keygen, followed by your server hostname. For example:

ssh-keygen -R server.example.com

This won’t ask you if you want to delete the specified lines, so make sure you’re removing the right ones before proceeding:

Using ssh-keygen to delete from the known_hosts file.

Using ssh-keygen to delete from the known_hosts file.

Once this is done, you shouldn’t get the “Warning: Remote host identification has changed” error from there on out.

Ever seen this error? 😅 It’s not always a bad thing (it’s protecting your connection from malicious attacks!), but it can be accidentally caused by your own activity. 😬 Learn more in this guide ⬇️Click to Tweet

Summary

Web security isn’t just about installing plugins and creating a strong password. The connections you use to log into servers need your utmost attention. If you don’t want to be subject to a machine-in-the-middle attack, you’ll want to use SSH access when you log in.

However, the system works almost too well. You may get the “Warning: Remote host identification has changed” error for a few reasons, and some are innocent.

Regardless, you can fix the error in no time through a Command Prompt or Terminal, using just a handful of commands.


Get all your applications, databases and WordPress sites online and under one roof. Our feature-packed, high-performance cloud platform includes:

  • Easy setup and management in the MyKinsta dashboard
  • 24/7 expert support
  • The best Google Cloud Platform hardware and network, powered by Kubernetes for maximum scalability
  • An enterprise-level Cloudflare integration for speed and security
  • Global audience reach with up to 35 data centers and 275 PoPs worldwide

Test it yourself with $20 off your first month of Application Hosting or Database Hosting. Explore our plans or talk to sales to find your best fit.

A secure internet connection is not just the ideal — it’s essential. In fact, we’re going to go as far as saying it’s the number one priority for your website. The “Warning: Remote host identification has changed” error protects your connection from certain malicious attacks, although in some cases, you can inadvertently cause the error too.

The error is related to your Secure Shell (SSH) keys and the server “fingerprint” a client will check for. If Secure Shell thinks there’s an issue, it will block access to your server and throw an error. But you can fix this in a few steps.

Over the next few minutes, we’re going to show you how to fix the “Warning: Remote host identification has changed” error for both Windows and Mac. First, though, let’s give you some more details on the error message itself.

A secure internet connection is not just the ideal — it’s essential 💪 While it may be annoying, this error protects your connection from attacks. 🙅‍♀️ Learn more ⬇️Click to Tweet

What the “Warning: Remote Host Identification Has Changed” Error Is

One of the most secure ways to connect to a web server is to use SSH. It’s a command-line tool that lets you access an insecure network securely. Consider it like a “super-SFTP” type of setup, although it’s not a 1:1 comparison in practice.

You can access your site from almost anywhere you can use the internet, as long as you have the right login credentials. What’s more, most macOS and Linux machines have an SSH client built into the Operating System (OS). For Windows, you’ll use a dedicated interface (and we’ll talk about this in more detail later).

As for the “Warning: Remote host identification has changed” error, it relates to the security checks your client will do. An SSH connection uses dedicated “keys” — small files stored on your computer — as authentication. It’s sort of like a Secure Sockets Layers (SSL) handshake, and in fact, there are some high-level similarities between SSH and SSL.

One aspect the keys help with is to provide a permanent fingerprint of its host server. This will make sure the connection is accurate and that you’re not subject to a “machine-in-the-middle” attack.

If the client thinks those fingerprints differ from what it understands to be correct, you’ll get the “Warning: Remote host identification has changed” error at the point of login:

[[email protected] ~]$ ssh [email protected]

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

Someone could be eavesdropping on you right now (man-in-the-middle attack)!

It is also possible that a host key has just been changed.

The fingerprint for the RSA key sent by the remote host is

xx:xx:xx.

Please contact your system administrator.

Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message.

Offending RSA key in /var/lib/sss/pubconf/known_hosts:4

RSA host key for user has changed and you have requested strict checking.

Host key verification failed.

As errors go, this is detailed and clear — it tells you what’s happened, a potential reason for why, and how you might fix it.

However, there’s one aspect we can touch on a little further before showing you how to fix the “Warning: Remote host identification has changed” error.

How the known_hosts File Helps SSH Authentication

You’ll notice that the error message references a known_hosts file. The name should give you a clue as to what it contains, but for clarity, it’s a list of SSH remote hosts known to the computer. It’s used as a reference client file for the authentication process.

When you first connect to a server, you’ll often get a confirmation request through your interface, asking whether you want to connect. If so, this fingerprint will become part of your known_hosts file.

Of course, if the fingerprint differs from what is in the known_hosts file, this could indicate a malicious user is targeting you. In other cases, you may already know why there’s a difference, although it pays to be vigilant regardless.

How To Fix the “Warning: Remote Host Identification Has Changed” Error (on Windows and Mac)

You can work to fix the “Warning: Remote host identification has changed” error for both Windows and macOS. However, you have more flexibility for doing so on Mac.

We’ll cover lots of the ways you can make things right again, starting with Windows.

1. Windows

It’s important to note that Windows machines might not have a known_hosts file. However, if you use the OpenSSH client, there is a file. To find it, open the Windows search bar, and navigate to your user folder with the %USERPROFILE% command.

This will open the directory within the File Explorer. There will also be a .ssh folder within:

The Windows File Explorer.

The Windows File Explorer.

The file we want in this folder is known_hosts. You can open this with Notepad (or your favorite text editor). Inside will be a list of keys:

The Windows known_hosts file.

The Windows known_hosts file.

Here, you can delete the key that’s causing the problem, then resave the file.

Some users may prefer the PuTTY client. The keys sit in the Registry, although they perform the same purpose as OpenSSH.

You’ll want to open the Windows Registry Editor (otherwise known as “regedit”). You can do this in whatever way you’re comfortable, but the quickest way is to type the app’s name into Window’s search bar:

The Registry Editor link in the Windows Start menu.

The Registry Editor link in the Windows Start menu.

Here, look for the following destination within regedit:

HKEY_CURRENT_USER/Software/SimonTatham/PuTTY/SshHostKeys/

You’ll see a list of entries here relating to the saved connections on your computer. Your job is to delete whichever one is causing an issue:

Deleting a Registry key in regedit.

Deleting a Registry key in regedit.

Once you click on the Delete button, you’ll also need to confirm that you want to remove the key:

The Confirm Value Delete dialog.

The Confirm Value Delete dialog.

Clicking Yes here means the key will be gone for good, and you shouldn’t get the “Warning: Remote host identification has changed” error any longer.

2. Mac

The Mac has a couple of ways to fix the “Warning: Remote host identification has changed” error — either through a premium app such as SSH Config Editor or the Terminal. The results will be the same, so we advise you to choose whichever option is more comfortable (and budget-friendly).

Our preferred approach is to access the file within a Terminal window (or iTerm2 if you use that app), and also open it with a dedicated Nano or Vim editor. This is because it’s accessible to everyone and straightforward to use regardless of your experience level.

Here, we’re going to use Nano. First, open your Terminal using whatever process is most comfortable:

Opening the Terminal from Spotlight.

Opening the Terminal from Spotlight.

From here, run the nano ~/.ssh/known_hosts command in your window. This will open a new Nano instance and display the keys within your known_hosts file:

The Nano editor with the known_hosts file open.

The Nano editor with the known_hosts file open.

You should delete the key causing the “Warning: Remote host identification has changed” error, then save your changes.

You might also want to delete the entire known_hosts file, especially if you only use SSH for one or two sites. To do this, you can run rm .ssh/known_hosts in a Terminal window.

There’s one more method to alter the known_hosts file on Mac: using the ssh-keygen utility from the command line. This is great if you don’t want to dig into the file itself, or if you want to work with only one site or key.

To achieve this, open a Terminal window and run ssh-keygen, followed by your server hostname. For example:

ssh-keygen -R server.example.com

This won’t ask you if you want to delete the specified lines, so make sure you’re removing the right ones before proceeding:

Using ssh-keygen to delete from the known_hosts file.

Using ssh-keygen to delete from the known_hosts file.

Once this is done, you shouldn’t get the “Warning: Remote host identification has changed” error from there on out.

Ever seen this error? 😅 It’s not always a bad thing (it’s protecting your connection from malicious attacks!), but it can be accidentally caused by your own activity. 😬 Learn more in this guide ⬇️Click to Tweet

Summary

Web security isn’t just about installing plugins and creating a strong password. The connections you use to log into servers need your utmost attention. If you don’t want to be subject to a machine-in-the-middle attack, you’ll want to use SSH access when you log in.

However, the system works almost too well. You may get the “Warning: Remote host identification has changed” error for a few reasons, and some are innocent.

Regardless, you can fix the error in no time through a Command Prompt or Terminal, using just a handful of commands.


Get all your applications, databases and WordPress sites online and under one roof. Our feature-packed, high-performance cloud platform includes:

  • Easy setup and management in the MyKinsta dashboard
  • 24/7 expert support
  • The best Google Cloud Platform hardware and network, powered by Kubernetes for maximum scalability
  • An enterprise-level Cloudflare integration for speed and security
  • Global audience reach with up to 35 data centers and 275 PoPs worldwide

Test it yourself with $20 off your first month of Application Hosting or Database Hosting. Explore our plans or talk to sales to find your best fit.


Linux

  • 03.04.2018
  • 21 506
  • 4
  • 12.03.2019
  • 19
  • 19
  • 0

Исправляем ошибку: warning: remote host identification has changed

  • Содержание статьи
    • Описание ошибки
    • Причина возникновения ошибки
    • Как ее исправить
    • Комментарии к статье ( 4 шт )
    • Добавить комментарий

Данная ошибка может появляться при попытке подключения к другому компьютеру через ssh и sftp протоколы.

Описание ошибки

Полностью она выглядит так:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:5VLqurxCsGZoX78FWhcaEQkHwAtq+Xzp1tBfOxKQQzE.
Please contact your system administrator.
Add correct host key in /home/ajiekceu4/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/ajiekceu4/.ssh/known_hosts:5
remove with:
ssh-keygen -f «/home/ajiekceu4/.ssh/known_hosts» -R sysadmin.ru
ECDSA host key for sysadmin.ru has changed and you have requested strict checking.
Host key verification failed.

Причина возникновения ошибки

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

  • Был изменен сертификат на устройстве и соответственно поменялся ECDSA ключ (из соображений безопасности, например);
  • Переустановлена ОС на устройстве и соответственно изменился сертификат;
  • Кто то пытается вас обмануть;

Как ее исправить

Если вы точно знаете, что сертификат на удаленном устройстве, к которому вы пытаетесь подключиться изменился и это не попытка вас обмануть со стороны заинтересованных лиц, то исправить эту ошибку очень просто. Необходимо просто удалить текущий ключ для данного домена (в нашем примере sysadmin.ru), сделать это можно командой, которая описана в самом тексте ошибки:

ssh-keygen -f "/home/ajiekceu4/.ssh/known_hosts" -R sysadmin.ru

В случае успеха, вывод команды должен быть примерно таким:

# Host sysadmin.ru found: line 10
/home/ajiekceu4/.ssh/known_hosts updated.
Original contents retained as /home/ajiekceu4/.ssh/known_hosts.old

После этого, необходимо еще раз попытаться подключиться к удаленному хосту и подтвердить установку нового ключа, написав «yes»

ssh root@sysadmin.ru
The authenticity of host 'sysadmin.ru (88.99.12.44)' can't be established.
ECDSA key fingerprint is SHA256:5VLaarxCsGZcv78FWphaEQkHwAtq+Zzp1tBfOXKQQzE.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'sysadmin.ru' (ECDSA) to the list of known hosts.

Перейти к содержанию

На чтение 3 мин Опубликовано 26.05.2020

Сегодня я попытался подключиться по SSH к моему удаленному серверу Ubuntu 20.04 LTS и обнаружил следующее сообщение:

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

$ ssh itsecforu@192.168.225.52
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:K/jEKNQCYYOilJxOZc7qAWlu4xu0nW+MD09DfJL7+gc.
Please contact your system administrator.
Add correct host key in /home/itsec/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/itsec/.ssh/known_hosts:11
  remove with:
  ssh-keygen -f "/home/itsec/.ssh/known_hosts" -R "192.168.225.52"
ECDSA host key for 192.168.225.52 has changed and you have requested strict checking.
Host key verification failed.

На самом деле это не сообщение об ошибке.

Это просто уведомление о безопасности, которое указывает, что ключ хоста ECDSA для данной удаленной системы изменился с момента вашего последнего подключения.

Как вы, возможно, уже знаете, когда мы впервые обращаемся к удаленной системе из локальной системы через SSH, отпечаток ключа ECDSA, отправленный этим удаленным хостом, кэшируется и сохраняется в файле $ HOME/.ssh/known_hosts в нашей локальной системе.

Когда идентификатор (отпечаток) изменился после переустановки удаленной системы или назначения одного и того же IP-адреса для нескольких удаленных систем, появляется указанное выше предупреждение.

Как исправить ошибку

Чтобы устранить эту проблему, просто удалите кэшированный ключ для IP-адреса в локальной системе с помощью команды:

$ ssh-keygen -R 192.168.225.52

Пример вывода:

# Host 192.168.225.52 found: line 11
/home/itsec/.ssh/known_hosts updated.
Original contents retained as /home/itsec/.ssh/known_hosts.old

Вы также можете явно указать путь к файлу known_hosts с флагом -f, как показано ниже.

$ ssh-keygen -f "/home/itsec/.ssh/known_hosts" -R "192.168.225.52"

Приведенная выше команда удалит все ключи, принадлежащие удаленному хосту, из файла known_hosts локальной системы.

А также старое содержимое файла known_hosts будет сохранено в файле с именем «known_hosts.old».

Если вы используете другой порт SSH, вам нужно явно указать его, как показано ниже:

$ ssh-keygen -R 192.168.225.52:1234

Здесь 1234 – номер порта SSH.

Замените его вашим фактическим номером порта SSH.

После удаления ключей попробуйте снова подключиться к SSH в удаленной системе с помощью команды:

$ ssh itsecforu@192.168.225.52

Введите «yes» и нажмите ENTER, чтобы добавить ключ удаленного хоста в вашу локальную систему:

The authenticity of host '192.168.225.52 (192.168.225.52)' can't be established.
ECDSA key fingerprint is SHA256:K/jEKNQCYYOilJxOZc7qAWlu4xu0nW+MD09DfJL7+gc.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.225.52' (ECDSA) to the list of known hosts.
itsecforu@192.168.225.52's password:

Теперь вы можете получить доступ к удаленной системе по SSH.

Пожалуйста, не спамьте и никого не оскорбляйте.

Это поле для комментариев, а не спамбокс.

Рекламные ссылки не индексируются!

SSH или Secure Shell — очень распространенный способ безопасного доступа к удаленным машинам, обычно через командную строку. Он направлен на то, чтобы ваше соединение и, следовательно, все передаваемые данные были свободны от подслушивания. Из-за этого в популярные клиенты SSH, такие как OpenSSH [https://en.wikipedia.org/wiki/OpenSSH], встроено довольно много проверок, которые гарантируют, что ваше соединение не будет скомпрометировано. Ниже приведен пример одной из этих проверок, которая определяет, когда отпечаток пальца

SSH или Secure Shell — очень распространенный способ безопасного доступа
к удаленным машинам, обычно через командную строку. Он направлен на то,
чтобы ваше соединение и, следовательно, все передаваемые данные были
свободны от подслушивания. Из-за этого в популярные клиенты SSH, такие
как OpenSSH , встроено немало
проверок, которые гарантируют, что ваше соединение не будет
скомпрометировано.

Примером одной из этих проверок является следующий, который определяет,
когда был изменен отпечаток пальца сервера:

 $ ssh [email protected] 
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
 @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ 
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
 IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! 
 Someone could be eavesdropping on you right now (man-in-the-middle attack)! 
 It is also possible that a host key has just been changed. 
 The fingerprint for the ECDSA key sent by the remote host is 
 SHA256:hotsxb/qVi1/ycUU2wXF6mfGH++Yk7WYZv0r+tIhg4I. 
 Please contact your system administrator. 
 Add correct host key in /Users/scott/.ssh/known_hosts to get rid of this message. 
 Offending ECDSA key in /Users/scott/.ssh/known_hosts:47 
 ECDSA host key for ec2-192-168-1-1.compute-1.amazonaws.com has changed and you have requested strict checking. 
 Host key verification failed. 

Когда вы подключаетесь к серверу через SSH, он получает отпечаток ключа
ECDSA
, который затем сохраняет в вашем домашнем каталоге в
~/.ssh/known_hosts . Это делается после первого подключения к серверу,
и вам будет предложено следующее сообщение:

 $ ssh [email protected] 
 The authenticity of host 'ec2-192-168-1-1.compute-1.amazonaws.com (192.168.1.1)' can't be established. 
 ECDSA key fingerprint is SHA256:hotsxb/qVi1/ycUU2wXF6mfGH++Yk7WYZv0r+tIhg4I. 
 Are you sure you want to continue connecting (yes/no)? 

Если вы введете «да», то отпечаток пальца будет сохранен в known_hosts
, который SSH затем проверяет каждый раз, когда вы подключаетесь к этому
серверу.

Но что произойдет, если ключ ECDSA сервера изменился с момента вашего
последнего подключения к нему? Это настораживает, потому что на самом
деле это может означать, что вы подключаетесь к другому серверу, не зная
об этом. Если этот новый сервер является вредоносным, он сможет
просматривать все данные, отправляемые в ваше соединение и из него,
которые могут быть использованы любым, кто настраивал сервер. Это
называется атакой «человек
посередине» .
Этот сценарий в точности соответствует сообщению «ПРЕДУПРЕЖДЕНИЕ:
ИДЕНТИФИКАЦИЯ УДАЛЕННОГО ХОЗЯКА ИЗМЕНИЛАСЬ!» сообщение пытается вас
предупредить.

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

Устранение проблемы

Если вы на 100% уверены, что это ожидаемое поведение и что нет
потенциальной проблемы с безопасностью, вам необходимо исправить
проблему, прежде чем продолжить.

Я нашел два самых простых способа решить эту проблему.

Разрешить вручную через known_hosts

  • В предупреждающем сообщении найдите строку, которая сообщает вам,
    где находится проблемный ключ ECDSA в файле known_hosts В моем
    примере в этой строке говорилось «Нарушение ключа ECDSA в
    /Users/scott/.ssh/known_hosts:47», что относится к строке 47.
  • Откройте known_hosts указанный в предупреждающем сообщении.
  • Удалить строку, указанную в предупреждающем сообщении

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

Разрешить с помощью ssh-keygen

Другое решение — использовать утилиту
ssh-keygen known_hosts
ключа из вашего файла known_hosts, что можно сделать с помощью следующей
команды:

 $ ssh-keygen -R [hostname-or-IP] 

Итак, в моем примере я бы использовал это так:

 $ ssh-keygen -R ec2-192-168-1-1.compute-1.amazonaws.com 

Этот метод хорош, если вы не хотите вручную изменять known_hosts , а
утилиту проще использовать, если вам нужно исправить несколько имен
хостов и IP-адресов. Он также может обрабатывать хешированные
known_hosts.old хостов в файле known_hosts.old.

Давайте разберемся с известнейшей проблемой, часто возникающей при подключении по протоколу ssh!

По умолчанию, для большей безопасности, в настройках ssh значение параметра StrictHostKeyChecking установлено в ‘yes’. Именно поэтому при первом подключении к удаленному хосту можно увидеть следующее:

The authenticity of host '192.168.0.166 (192.168.0.166)' can't be established.
ECDSA key fingerprint is f0:74:54:33:93:bd:73:d1:ef:d6:fe:47:d3:93:e0:7f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.166' (ECDSA) to the list of known hosts.

Введя в консоли ‘yes’, мы подтверждаем, что действительно хотим подключиться к этому хосту и отпечаток его ssh-ключа добавляется в файл ~/.ssh/known_hosts.

При повторной попытке подключения к хосту после изменения ключа на удаленном сервере (как правило, он меняется если была переустановлена операционная система или sshd), появляется сообщение с ошибкой:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
ae:a6:0b:8d:14:e4:3c:67:f0:a3:ec:a9:9e:2a:26:72.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:75
  remove with: ssh-keygen -f "/root/.ssh/known_hosts" -R 192.168.0.166
ECDSA host key for 192.168.0.166 has changed and you have requested strict checking.
Host key verification failed.
lost connection

Для устранения данной проблемы необходимо удалить строку с указанным ssh-ключом из файла /root/.ssh/known_hosts. Сделать это можно несколькими способами.

Первый (указан в самом сообщении с ошибкой):

ssh-keygen -f "/root/.ssh/known_hosts" -R 192.168.0.166
# Host 192.168.0.166 found: line 75 type ECDSA
/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old

Второй вариант удаления ключа:

sed -i '75d' /root/.ssh/known_hosts

Примечание. Номер строки с ssh-ключем, который нужно удалить, указывается с помощью ‘75d’.

Третий вариант удаления ключа (с использованием perl):

perl -pi -e 's/Q$_// if ($. == 75);' /root/.ssh/known_hosts

После проделанных действий пробуем подключиться по ssh к удаленному хосту — проблема должна исчезнуть.

Ошибка возникающая при подключении на Mac OS к серверу по SSH в том случае, если сервер был переустановлен и изменил свою конфигурацию.

При первом подключении в операционной системе Mac OS к удалённому серверу сохраняется уникальный идентификатор ECDSA key fingerprint.

MAC_name:~ User_name$ ssh root@111.111.111.111
The authenticity of host ‘111.111.111.111 (111.111.111.111)’ can’t be established.
ECDSA key fingerprint is SHA256:JoLuu0OG8Fu5nAkyfsgFGHM347sN/FGsm37xnsGJS.
Are you sure you want to continue connecting (yes/no)? y
Please type ‘yes’ or ‘no’: yes

И если на стороне сервера меняется его конфигурация, то сохранённый fingerprint к этому ip адресу уже не подходит. При подключении через Терминал в Mac Os к серверу будет возникать ошибка следующего рода:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:JoLuu0OG8Fu5nAkyfsgFGHM347sN/FGsm37xnsGJS.
Please contact your system administrator.
Add correct host key in /Users/User_name/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/User_name/.ssh/known_hosts:5
ECDSA host key for 111.111.111.111 has changed and you have requested strict checking.
Host key verification failed.

Для исправления ошибки нужно удалить fingerprint к этому ip адресу.

Вариант 1

Используем консольную команду:

ssh-keygen -R 111.111.111.111

вместо единичек надо указать свой адрес.

И fingerprint будет удален из файла known_hosts:

MAC_name:~ User_name$ ssh-keygen -R 111.111.111.111
# Host 111.111.111.111 found: line 5
/Users/User_name/.ssh/known_hosts updated.
Original contents retained as /Users/User_name/.ssh/known_hosts.old

Предыдущая версия файла known_hosts будет сохранена с именем known_hosts.old.

Вариант 2

Открыть файл через known_hosts:

И удалить там строку с нужным ip адресом.

После чего можно заново подключаться.

Понравилась статья? Поделить с друзьями:
  • Warning postscript error no pdf file produced
  • Warning please insert usb key press any key to check как исправить
  • Warning please backup your data and replace your hard disk drive как исправить
  • Warning pe012 parsing restarts here after previous syntax error
  • Warning no address error 126 wolfenstein ii the new colossus