Share via

after resizing a virtual machine I cannot connect via ssh

Tucker Thames 0 Reputation points
2026-05-06T16:17:17.5466667+00:00

after resizing a virtual machine I cannot connect via ssh. I can connect via the serial console. I have tried a number of steps including redeploying and re-applying, reverting back to the old size, double checking nsg rules, opening up nsg rules temporarily to allow any source, creating a new key to ensure I am using a valid key pair, and more suggestions from co-pilot and gmeini. No matter what when I try to connect i get a Network Error: Connection timed out.

Has anyone had this issue?

Azure Virtual Machines
Azure Virtual Machines

An Azure service that is used to provision Windows and Linux virtual machines.


1 answer

Sort by: Most helpful
  1. Q&A Assist
    2026-05-06T16:17:31.5933333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Resizing can expose or change underlying compute/network behavior, so focus on verifying that SSH is actually listening and reachable from inside the VM, then work outward.

    Since Serial Console works, use it (or Run Command) to run these checks and fixes:

    1. Confirm SSH service is running and listening In Serial Console:
         sudo systemctl status sshd.service
      
      If it is not active (running), start/restart it:
         sudo systemctl restart sshd.service
      
      Then verify it is listening on the expected port (usually 22):
         sudo ss --listen --tcp --process --numeric | grep sshd
      
      Expected output should show something like:
         LISTEN 0 128 0.0.0.0:22 ...
         LISTEN 0 128 [::]:22   ...
      
      If nothing is returned, SSH is not listening; reset the SSH configuration (step 3).
    2. Confirm SSH port configuration Still in Serial Console, check /etc/ssh/sshd_config:
         grep -i port /etc/ssh/sshd_config
         grep -i listen /etc/ssh/sshd_config
      
      If no non-comment Port line is present, default is port 22. If a different port is configured, ensure that is the port being used from the client and allowed in NSG.
    3. Reset SSH configuration from Azure side If SSH is not running or appears misconfigured, reset it to defaults using Azure CLI:
         az vm user reset-ssh --resource-group <yourRG> --name <yourVM>
      
      This resets SSH configuration without changing users or keys. If needed, also reset credentials/keys:
         az vm user update --resource-group <yourRG> --name <yourVM> \
             --username <user> --ssh-key-value "$(cat ~/.ssh/id_rsa.pub)"
      
      Alternatively, use the VMAccess extension with a settings.json containing:
         { "reset_ssh": true }
      
      and apply it:
         az vm extension set --resource-group <yourRG> --vm-name <yourVM> \
             --name VMAccessForLinux --publisher Microsoft.OSTCExtensions \
             --version 1.2 --settings settings.json
      
    4. Verify NSG and networking again (post-resize) After confirming SSH is listening on the VM:
      • Ensure the NIC/subnet NSG has an inbound rule allowing TCP 22 from the client IP.
      • Confirm there is no higher-priority deny rule blocking it.
      • If using a different SSH port, allow that port instead.
      • Check that the VM still has the expected public IP and that any upstream firewall allows SSH.
    5. Check VM health and restart/redeploy if needed
      • In the portal, verify Resource health is healthy and boot diagnostics show no boot errors.
      • If everything looks healthy but SSH still times out, restart the VM:
        • Portal: select the VM → Restart.
        • CLI:
                 az vm restart --resource-group <yourRG> --name <yourVM>
          
      • If the issue persists, redeploy the VM to a new node (noting ephemeral disk data loss and dynamic IP changes) using Redeploy in the portal or:
             az vm redeploy --resource-group <yourRG> --name <yourVM>
        
    6. Use Run Command if Serial Console is limited If Serial Console is restricted (for example, key-only auth issues), use Run Command in the Azure portal to run the same systemctl, ss, and grep commands non-interactively and inspect output.

    Following this sequence ensures SSH is running and listening inside the VM, correctly configured on the expected port, and reachable through Azure networking after the resize.


    References:

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.