question

SA-7536 avatar image
0 Votes"
SA-7536 asked SA-7536 commented

Accessing Ubuntu VM while SSH daemon is modified and cannot open socket

Hello,

I was able to SSH into Ubuntu VM and things were working fine. Last time, I made some change to /lib/systemd/system/ssh.service (ssh daemon) which loads my shared library. Unfortunately, before stopping the VM I forgot to undo the changes and now, due to my shared library, it seems that the sshd is unable to open a socket. As a result, I am unable to ssh into my VM. I think if I get access to VM and undo the changes in /lib/systemd/system/ssh.service then things will work perfectly.

I don't whether there is another way of accessing my VM and it seems that the SSH is the only way to access, therefore, I have ended up in this situation. I have tried both RDP and Azure Bastion, and nothing is working. I am not whether I created any password and the ones that I remember are not working.

How to access the VM? What can I do to safe the data in my VM?

Please let me know. Thanks!

azure-virtual-machinesazure-virtual-machines-networking
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@SA-7536
office-teams-linux-itpro tag is for Microsoft Teams running on Linux operating system. Your question is more related to the Linux, but not Microsoft Teams. I will remove this irrelated tag. Thanks for your understanding.

0 Votes 0 ·

1 Answer

srbose-msft avatar image
1 Vote"
srbose-msft answered SA-7536 commented

@SA-7536 , thank you for your question.

You might want to try any of the following options:

  • Azure Serial Console

    The Serial Console in the Azure portal provides access to a text-based console for virtual machines (VMs) and virtual machine scale set instances running either Linux or Windows. This serial connection connects to the ttyS0 or COM1 serial port of the VM or virtual machine scale set instance, providing access independent of the network or operating system state. The serial console can only be accessed by using the Azure portal and is allowed only for those users who have an access role of Contributor or higher to the VM or virtual machine scale set.

    Serial Console is generally available in global Azure regions and in public preview in Azure Government. It is not yet available in the Azure China cloud.

    Please read the Prerequisites to access the Azure Serial Console.
    For detailed steps check Get started with the Serial Console

    OR

  • Recovering Azure VM by attaching OS disk to another Azure VM
    1. Create a temporary Linux Azure Virtual Machine (we shall refer to this new VM as the Recovery VM henceforth). [How-to guide]

    2. Mount a copy of the impacted VM's OS disk as a data disk on the Recovery VM. You can find a list of steps here.

    3. SSH to the Recovery VM and fix the issues on the mounted copy of the impacted VM's OS disk.

    4. Detach the mounted copy of the impacted VM's OS disk from the recovery VM. [How-to guide]

    5. Swap the OS disk on the impacted VM with the copy (which now has the fix). [How-to guide]


Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as convenient to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


Hope this helps.

Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.

· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your detailed response!

It seems the Serial Console is not working for me despite creating a custom storage account because I am not sure about the password and have only the ssh key.

Let me try the second option and will update you.

0 Votes 0 ·

@SA-7536 , thank you for your response. You can reset the password in a few easy steps using the instructions shared here. You can find more information on the az vm user update command and examples here.

0 Votes 0 ·

Thanks again!

Does it still work if no password was used when the VM was deployed?

Is it possible to create a new sudo user (abc_sudo) and user Serial Console to sign in using abc_sudo?

Thanks!

0 Votes 0 ·
Show more comments