PUTTY无法连接至Azure Linux(Ubuntu 18.04)虚拟机的技术求助
Hey there, let's work through this PuTTY connection issue with your Azure Ubuntu 18.04 VM step by step. I’ve helped folks troubleshoot this exact scenario plenty of times, so let’s start with the most common fixes first:
1. Verify VM Network & Security Settings
- First, confirm your VM has a public IP address assigned (check this in the Azure portal under your VM's "Networking" tab). Without a public IP, you can't reach it directly from your local machine.
- Check the attached Network Security Group (NSG) to ensure inbound traffic on port 22 (SSH) is allowed. Head to the NSG's "Inbound security rules"—there should be a rule permitting port 22 from your local IP (or use
0.0.0.0/0temporarily for testing, though avoid this long-term for security).
2. Double-Check PuTTY Configuration
- When entering your VM's public IP in PuTTY, make sure the port is set to 22 (unless you explicitly changed the SSH port on your VM).
- If using SSH keys (the recommended method):
- PuTTY can't use standard PEM keys directly—you need to convert your private key to PuTTY's PPK format with PuTTYgen. Open PuTTYgen, click "Load", select your private key file (set the filter to "All Files" to see it), then click "Save private key" to generate the PPK.
- In PuTTY, navigate to Connection > SSH > Auth and browse to select the PPK file you created.
- If using password authentication:
- Ensure password login is enabled on the VM. Use the Azure portal's "Connect > SSH" option to access the VM first, then edit
/etc/ssh/sshd_configand setPasswordAuthentication yes. Restart the SSH service withsudo systemctl restart sshd, then try PuTTY again.
- Ensure password login is enabled on the VM. Use the Azure portal's "Connect > SSH" option to access the VM first, then edit
3. Check the VM's SSH Service
- Use the Azure portal's "Serial Console" (under "Support + troubleshooting" for your VM) to log into the VM. Run
sudo systemctl status sshdto confirm the SSH daemon is running. If it's stopped, start it withsudo systemctl start sshd. - Verify the daemon is listening on port 22 with
sudo netstat -tulpn | grep sshd—you should see an entry for0.0.0.0:22or:::22.
4. Resolve Host Key Warnings/Errors
- If PuTTY warns about an unrecognized host key, that's normal on first connection—click "Yes" to cache it. If you get a "host key changed" error, this usually means the VM was recreated or you're using the wrong IP. Double-check the VM's public IP in Azure.
5. Rule Out PuTTY-Specific Issues (Optional)
- Test connecting from your local machine's built-in SSH client (if on Linux/macOS) with
ssh your-username@vm-public-ip. If this works, the problem is definitely in your PuTTY setup; if it fails, the issue lies with the VM or network configuration.
内容的提问来源于stack exchange,提问作者Raj Gohel
相关产品推荐
相关产品推荐

