Azure环境下Windows远程访问Linux虚拟机时出现连接错误
Hey there, let’s work through the most likely fixes for your Putty connection issue—since you’ve already completed the initial setup steps, these are the top things to check first:
Verify Azure Network Security Group (NSG) Rules
Head to your VM in the Azure portal → Networking → Inbound port rules. Make sure there’s an active rule allowing SSH traffic (default port22) from your local public IP address. For testing, you can temporarily set the source to "Any" (just remember to lock it down to your IP afterward) to rule out NSG blockages.Confirm VM Public IP/DNS and Running Status
Double-check that the public IP or DNS name you’re using in Putty matches what’s listed on your Azure VM’s overview page. Dynamic IPs can change if you restarted the VM, so this is a common gotcha. Also, ensure the VM shows as Running in the portal—if it’s stopped/deallocated, start it up first.Check the SSH Service on Your VM
Use the Azure portal’s Serial Console to log into your VM directly (no SSH needed) and runsystemctl status sshd(for Linux VMs). This will tell you if the SSH service is active. If it’s stopped, start it withsystemctl start sshdand enable it to run on boot withsystemctl enable sshd.Audit Putty Configuration
- Make sure you’ve selected SSH as the connection type and port
22(unless you changed the default SSH port on your VM). - If using a private key, confirm you’ve loaded the correct
.ppkfile under Connection → SSH → Auth → Private key file for authentication. If you have an OpenSSH key, you’ll need to convert it to PPK format using Puttygen first. - Disable any proxy settings in Putty (Connection → Proxy) unless you explicitly need a proxy to connect—unintended proxies often block SSH traffic.
- Make sure you’ve selected SSH as the connection type and port
Rule Out Local Network Restrictions
Your local firewall or ISP might be blocking outbound SSH on port 22. Test connecting from a different network (like a mobile hotspot) to see if the issue goes away—this will confirm if the problem is on your end or with the VM.
If you can share the exact error message from your screenshot, we can narrow this down even further! For example, "Connection refused" usually points to NSG or SSH service issues, while "Host key verification failed" relates to key mismatches.
内容的提问来源于stack exchange,提问作者Deepanshi Bansal

