I can't connect my VM via ssh

子轩 王 25 Reputation points
2023-01-25T12:44:19.5633333+00:00

server: azure 1Bs ubuntu 20.04

When I created the virtual machine, I successfully logged into the vm using the private key. But the next day I used the same method to log in but it was prompted that the login timed out. Right now I can only use serialconsole and bastion to connect to my vm.

  1. I try to connect to my vm using other devices and IPs, but it still fails.
  2. I try to create a new user in the system and log in with the password ssh, but I still can't connect.
  3. I used the telnet command to test that port 22 could not be connected, so I turned off the security policy of azure, but still could not connect. It seems that there are some policies between my computer and vm that prevent normal connections?

At the same time none of my applications running on the vm are accessible. What can be ensured is that these programs are running normally.

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

Accepted answer
  1. deherman-MSFT 33,456 Reputation points Microsoft Employee
    2023-01-25T18:53:43.53+00:00

    I understand you have an Ubuntu VM but have lost SSH connection and application access to services on the VM.

    Since you are receiving a timeout, this likely means there is a network issue preventing access. To isolate if there is a network security group blocking the connection you can use the Network security group test from the portal.

    1. In the Azure portal, navigate to the VM that you want to test the connection to.
    2. In the VM's "Overview" page, click on "Connect" button.
    3. Click on "Test your connection" link.
    4. After the test completes it will alert you if there is a NSG blocking.

    If there is not a NSG blocking the connection, you can use the "Troubleshoot SSH connectivity issues" link. This will let you know of any recent changes. You can select "Cannot Connect to VM" to be guided through steps to resolve the issue.

    User's image

    User's image

    Hope this helps! If you the above doesn't resolve your issue please let me know and we can work with you directly to diagnose further.


    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


0 additional answers

Sort by: Most helpful