I'm getting 'Permission denied' message when attempting to SSH to VM in sandbox

Steve Troughton 0 Reputation points
2023-11-21T10:45:37.6966667+00:00

I'm doing the 'Secure storage for Azure Files and Blob Storage' Applied Skills course on Microsoft Learn. On module 5 (Secure and isolate...), unit 3 (Create and manage NSGs), the exercise uses a sandbox with Azure CLI.

I'm able to create the vnet, nsg and VMs, however, when I try to connect to the VMs via SSH, I just keep getting a 'Permission denied' message, as if the password is wrong. I know I'm entering the password correctly but the message persists. Here's the command I'm using to connect:

ssh azureuser@13.64.148.121 -o ConnectTimeout=5

The SSH rule (port 22) is set up correctly on the NSG

Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
1,638 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Adam Zachary 2,911 Reputation points
    2023-11-22T04:50:26.91+00:00

    Hi Steve,

    If you cannot log in to the VM, here's what you can do:

    1. Use the Azure portal or Azure CLI to restart the VM, which can sometimes resolve such issues.
    2. Check the NSG rules to ensure SSH (port 22) is allowed from your IP address.
    3. Check the boot diagnostics in the Azure portal for any errors on startup that might indicate a service failure.
    4. Confirm if the SSH service is running on a VM from the Azure portal;
      • Go to the Azure portal.
        • Navigate to the Virtual Machines section and select your VM.
          • In the VM's blade, find and click on "Serial console" under the "Support + troubleshooting" section.
            • The Serial Console provides access to the VM's text-based console. You can use it to check the status of the SSH service by running a command like sudo service ssh status.

    Note: Ensure your VM’s boot diagnostics are enabled to use the Serial Console. If the SSH service isn't running, you can start it.

    Kindly if you find the provided information helpful and it resolves your query, please consider accepting the answer. Your feedback is valuable and helps ensure the quality and relevance of the responses.


Your answer

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