注释RSAAuthentication与PubkeyAuthentication后无法连接Azure Ubuntu虚拟机
Troubleshooting SSH Connection Failures to Azure Ubuntu VM
Let’s work through this step by step— I’ve debugged dozens of these Azure VM SSH issues, so let’s start with the most common culprits first:
1. Verify Azure Platform Network Configurations
Don’t skip this— Azure’s network rules often block SSH traffic even if your VM’s internal config is correct:
- Check Network Security Group (NSG) Inbound Rules:
Head to the Azure Portal, find your VM, navigate to its associated NSG. Ensure there’s an inbound rule allowing traffic on port 22 (SSH), with the source set to your development machine’s public IP (or temporarily set toAnyfor testing— just remember to lock it down later). - Confirm VM Public IP:
Azure VMs with dynamic IPs can change after a restart. Double-check the public IP in the Azure Portal matches what you’re entering in Bitvise. - Check VM Health Status:
Make sure the VM is in a "Running" state in the portal. If it’s stuck or has a fault, that could block connections entirely.
2. Validate VM Internal SSH Service & Config
You’ve modified sshd_config, but let’s make sure those changes are active and correct:
- Restart SSHD Service After Config Changes:
This is a super common oversight— any edits tosshd_configwon’t take effect until you restart the service. Run this command in your VM (use Azure Serial Console if you can’t SSH in):sudo systemctl restart sshd # For older Ubuntu versions, use: sudo service ssh restart - Double-Check
sshd_configSettings:
Open the file again withsudo nano /etc/ssh/sshd_configand verify these lines (ensure they’re not commented out with#):PasswordAuthentication yes(this is mandatory for password-based SSH)PermitRootLogin yes(only if you’re trying to log in as root; if using your admin user, this can beprohibit-password)- If you commented out
RSAAuthenticationandPubkeyAuthentication, that’s fine for password-only login— just make sure no other lines are overridingPasswordAuthentication.
- Check SSHD Logs for Exact Errors:
Logs will tell you why connections are failing (wrong password, user not allowed, config error, etc.). Run this to view recent SSH activity:
Look for lines likesudo journalctl -u sshd # Or check the auth log: sudo cat /var/log/auth.logFailed password for user XorConnection closed by Y [preauth]— these are direct clues to the problem.
3. Local Development Environment Checks
Sometimes the issue is on your end, not the VM:
- Test with Another SSH Client:
Try connecting with PuTTY or the Windows built-in SSH client (ssh username@vm-ip) to rule out a Bitvise-specific bug. - Verify Login Credentials:
Azure Ubuntu VMs don’t userootby default— make sure you’re using the admin username you set when creating the VM, not root. Double-check the password too (Azure sometimes auto-generates complex ones if you didn’t set your own). - Check Local Firewall/Proxy:
You configured Windows outbound rules, but some antivirus tools or proxies can still block SSH traffic. Try disabling your proxy temporarily, or adding an exception for Bitvise in your antivirus.
4. Quick Test with Azure Serial Console
If you’re still stuck, use the Azure Portal’s Serial Console to log into your VM directly:
- Once logged in, test SSH locally with
ssh localhost— if this works, the SSH service is running correctly, and the problem is definitely network-related. - If it fails, you’ll get an error message that points directly to the internal issue (e.g., SSH service not running, config error).
内容的提问来源于stack exchange,提问作者E. Erfan
相关产品推荐
相关产品推荐

