VS Code Remote-SSH Suddenly Stops Working?
페이지 정보
본문
🚨 VS Code Remote-SSH Suddenly Stops Working? (Permission Denied Fix on Windows)
If your VS Code Remote-SSH was working perfectly and then suddenly started throwing this error:
Permission denied (publickey)
…don’t panic.
Especially if:
-
✅ PuTTY still works
-
✅ Mac SSH works
-
❌ Only Windows VS Code Remote-SSH fails
Then this post will save you hours of frustration.
🔍 The Real Cause (Not What You Think)
At first, you might suspect:
-
SSH key mismatch ❌
-
Server issue ❌
-
Network problem ❌
But the real culprit is:
👉 Windows file permissions (ACL) on your private key
⚠️ Why This Happens
VS Code uses OpenSSH, which enforces strict security rules:
Your private key MUST be accessible only by you.
If your key file has extra permissions like:
-
Users
-
Administrators
-
CodexSandboxUsers
-
or inherited permissions
Then OpenSSH will REFUSE to use your key, even if it is correct.
You’ll see something like:
WARNING: UNPROTECTED PRIVATE KEY FILE!
This private key will be ignored.
💥 The Fix (Instant Solution)
Run these commands in PowerShell:
icacls "C:\Users\YOUR_USERNAME\Documents\putty\id_rsa" /inheritance:r
icacls "C:\Users\YOUR_USERNAME\Documents\putty\id_rsa" /grant:r YOUR_USERNAME:F
Example:
icacls "C:\Users\t1gum\Documents\putty\id_rsa" /inheritance:r
icacls "C:\Users\t1gum\Documents\putty\id_rsa" /grant:r t1gum:F
🔧 What These Commands Do
-
/inheritance:r → removes all inherited permissions
-
/grant:r YOUR_USERNAME:F → gives full access only to you
After this, your key becomes secure enough for OpenSSH to accept
🚀 Test Your Connection
Try again:
ssh -i C:\Users\YOUR_USERNAME\Documents\putty\id_rsa ubuntu@YOUR_SERVER_IP
If it works, VS Code Remote-SSH will also work again.
🧠 Why It “Suddenly” Broke
This usually happens because:
1. File permissions changed automatically
-
Moving files
-
Copying from another folder
-
Downloading again
2. Windows / OpenSSH update
Newer versions enforce stricter security rules.
3. VS Code Remote-SSH is stricter than PuTTY
PuTTY ignores permission issues.
OpenSSH does not.
💡 Best Practice (Avoid This Forever)
Always store your SSH keys here:
C:\Users\YOUR_USERNAME\.ssh\
Then secure it once:
icacls C:\Users\YOUR_USERNAME\.ssh\id_rsa /inheritance:r
icacls C:\Users\YOUR_USERNAME\.ssh\id_rsa /grant:r YOUR_USERNAME:F
And you’re done.
🎯 Final Summary
If VS Code Remote-SSH suddenly stops working:
👉 It’s NOT your server
👉 It’s NOT your key
👉 It’s your Windows file permissions
💬 One-Line Fix
icacls YOUR_KEY_PATH /inheritance:r
icacls YOUR_KEY_PATH /grant:r YOUR_USERNAME:F
If this saved you, bookmark it.
You will 100% run into this again 😎