virtual machine agent status is not ready

SoftComm SDC 1 Reputation point

my vm shows this warning message and I can't login with ssh (showing "ssh: connect to host ipaddress port 22: Connection refused" error message)

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
5,977 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Ronen Ariely 15,051 Reputation points


    (1) Next time please provide the exact message as text in addition to the screenshot

    XXX virtual machine agent status is not ready

    (2) if the agent is not in a ready state, it might be corrupted or not well installed. If you deployed the VM from image, then a manual installation is required for the Guest Agent. In both cases, You can simply manually reinstalling the agent in this case, as explained here:

    0 comments No comments

  2. srbhatta-MSFT 8,526 Reputation points Microsoft Employee

    Hello @SoftComm SDC ,

    Thank you for reaching out to Microsoft QnA. I would like to add to what @Ronen Ariely has already mentioned.

    Firstly, please confirm if you are able to login to the VM via serial console, because I have observed the the 'Connection refused' error is thrown mostly when there is a network issue. Then try the following steps depending on the individual possibilities..

    1. If SSH daemon inactive/dead

    Check the status of ssh daemon by running the following command systemctl status sshd. If you see that the service is inactive, you can run systemctl start sshd to start the service back again and then try to ssh into the VM. In case serial console is not working, you can check for the status of ssh daemon via Run command from the Portal on the VM blade by running the same commands as I mentioned above.


    2. If custom port has been configured for ssh

    Again, login via serial console. Then check "systemctl status sshd". The service will be up and running. Open the sshd configuration file with an editor.
    vi /etc/ssh/sshd_config , here check for the line containing the port and verify if you are using the same port or not for ssh.


    3. Corruption of sshd_config file

    Login via serial console, and check the status of ssh daemon. If you find the daemon in failed state, and even starting/restarting of the ssh service fails, then check the sshd_config file for any incorrect changes or corruption. Then, compare it with the config file of a working VM. Take a backup of the existing config file, remove the lines which appear to be incorrect and then try to restart the ssh service once the rectifications are done.

    4. Iptable rules blocking SSH connection

    Check for any iptable rule that might block he incoming SSH connection.

    In a completely different scenario, if you see the the VM's OS in an unhealthy state, then you will have to troubleshoot that accordingly. You will be able to figure the OS health by check the latest 'Boot diagnostics' screenshot/log. If you see that the OS is waiting at the login prompt, it means OS is healthy, however if you see some kernel errors it will indicate OS being in an unhealthy state.

    Now another important concept is that, it is not necessary that if the VM agent status is not ready, you will not be able to SSH into the VM. You should be able to SSH into your VM even if the Agent status is not ready because the Agent depends on other components.

    To understand and troubleshoot Linux VM Agent related issues, please refer to the below links:

    I hope this helps.


    Please don't forget to Accept as Answer and Upvote and if you think my response was helpful.

    0 comments No comments