Azure - Machine SSH not available

This article provides some resolution steps in case your machine is running but refusing SSH access. This kind of issue can be resolved through the Azure portal directly.






1 - Context

It may happen after restarting or booting an existing virtual machine that your machine refuses SSH access even though Azure indicates that your machine is running. This issue does not necessarily mean that your machine is having troubles and/or is down and may only be due to the main SSH service being not started properly.

If you try to connect to the machine via SSH it is likely that you will see this type of error (note the "-vvv" to be able full verbose mode):

ssh -vvv myuser@mymachine
# => ssh_exchange_identification: Connection closed by remote host


If you are using Ruby to connect to the machine - e.g. from the Nex!™ orchestrator - you will likely see errors like:

Net::SSH::Disconnect: connection closed by remote host


2 - Resolution steps

In order to resolve the problem above you can follow the steps below 

  1. Go to Azure portal
  2. Select the machine you have troubles with
  3. Go to the Reset Password section
  4. Select Reset Configuration Only in the dropdown
  5. Wait for the SSH reset to be done
  6. Try to SSH again to the machine

If the above does not work you can try to do a full SSH reset by entering a new SSH key

  1. Go to the Reset Password section
  2. Select Reset SSH Public Key in the dropdown
  3. Enter the new SSH public key for your machine and click save
  4. Wait for the SSH reset to be done
  5. Try to SSH again to the machine

3 - Reference article

Original article: https://docs.microsoft.com/en-gb/azure/virtual-machines/linux/troubleshoot-ssh-connection#fix-common-ssh-errors