Azure Linux Support Team

Support for Linux on Azure

Linux Recovery: SSH daemon is not starting up properly

You have noticed that you lost SSH connectivity to a Linux VM and after examining the boot diagnostics you see messages related to errors in the SSHD configuration.

The error around invalid configuration might be simply:
Starting sshd: [FAILED]

There were a few instances seen in SUSE and Red Hat where errors are seen due to permission issues, examples:

/var/lib/empty must be owned by root and not group or world-writable.
startproc:  exit status of parent of /usr/sbin/sshd: 255

Red Hat:
Starting sshd: /var/empty/sshd must be owned by root and not group or world-writable.

When the issue is clearly a configuration issue and not a permissions issue like the ones above (which we will cover on a different article), there are a few ways that we can try correcting the problem which is resetting the SSHD configuration to its defaults.

A) When using Classic and Resource Manager VMs , there are options on the portal that you can reset the SSHD configuration.

For Classic VMs
Virtual Machines (classic) > VMNAME > On the overview tab click under More and then “Reset Remote Access”



Then click yes to proceed.


For Resource Manager VMs
Virtual Machines > VMNAME > Reset Password, once you are there, you should see these options available:

Select the option that is more appropriate for the problem, in this case “Reset configuration only”.

B) If you are have the Azure CLI installed you can also reset the SSHD configuration file using:

For Classic VMs

# create a file PrivateConf.json with this content:
{ “reset_ssh”:  “True”}

The following commands will login with the azure cli, set the config to asm (Classic) and then reset the SSHD configuration:

azure login
azure config mode asm
azure vm extension set <VMNAME>  VMAccessForLinux Microsoft.OSTCExtensions 1.* –private-config-path PrivateConf.json

NOTE: Make sure you create the file PrivateConf.json in the same folder that you are running the azure cli command from or provide the absolute path.

For Resource Manager VMs

azure login
azure config mode arm
azure vm reset-access -r <RESOURCE_GROUP> <VMNAME>