I want to implement an Azure solution for 2VMs in the same Virtual Network to communicate together. VM1 has a public IP and VM2 a private IP and I want to be able to SSH into VM2 from VM1 to install a database application, how can I achieve this?

Mauyon Akinola 0 Reputation points
2023-10-06T18:41:04.03+00:00

I want to implement a solution for an application server (VM1) and a database server (VM2) which allows me to SSH into VM2 from VM1 in the same Virtual Network. VM1 has a public IP address and ports 22 & 80 are allowed in the NSG Group while VM2 has a private IP address with ports 22 & 3306 enabled. I have been unable to SSH into VM2 from VM1 as I got a "bad permission error" response, despite applying NAT & Bastion. Please help, there must be something I am missing.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,254 questions
Azure Bastion
Azure Bastion
An Azure service that provides private and fully managed Remote Desktop Protocol (RDP) and Secure Shell (SSH) access to virtual machines.
243 questions
Azure NAT Gateway
Azure NAT Gateway
NAT Gateway is a fully managed service that securely routes internet traffic from a private virtual network with enterprise-grade performance and low latency.
24 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Durkan 12,156 Reputation points MVP
    2023-10-07T12:26:49.7433333+00:00

    Hi

    a few queries that may help:

    Do the VM's reside in the same Subnet within the VNET, or different Subnets?

    Do you have NSG's applied at VNET, Subnet or directly on the VM NICs?

    Have you tried using Azure Network Watcher to assist with diagnosing the connectivity between the 2 endpoints?

    Hope this helps,

    Thanks

    Michael Durkan

    • If the reply was helpful please upvote and/or accept as answer as this helps others in the community with similar questions. Thanks!

  2. msrini-MSFT 9,261 Reputation points Microsoft Employee
    2023-10-07T23:31:08.4533333+00:00

    Hi,

    SSH to VM2 from VM1 can be achieved using the Private IP address. You can first login to the VM1 and then use the VM1's Private IP and try doing an SSH.

    Can you also post the exact error that you are getting ?

    Regards,

    Karthik Srinivas