DEV Community

SGTSanjay
SGTSanjay

Posted on

VSCode Remote SSH Development Guide for Magento 2

πŸ“Œ Overview

This guide helps you configure VSCode Remote SSH for Magento 2 development on a remote Linux (Red Hat) server.

What You Get

Full VSCode IDE on remote server

IntelliSense & PHP code navigation

Git UI + terminal workflow

GitHub Copilot / AI assistance

No file syncing, no SCP, no FTP

βœ… Prerequisites

VSCode installed on Windows

SSH access to remote server

.ppk private key

PuTTYgen (comes with PuTTY / WinSCP)

πŸ”Œ Step 1: Install Remote-SSH Extension

Open VSCode

Go to Extensions (Ctrl+Shift+X)

Search for Remote – SSH

Install Remote Development (by Microsoft)

πŸ” Step 2: Convert PPK to OpenSSH Format

VSCode uses OpenSSH, not .ppk.

βœ” Using PuTTYgen (Recommended)

Open PuTTYgen

Click Load

Select your .ppk file
Example:

D:\Docs\yourppk.ppk

Go to Conversions β†’ Export OpenSSH key

Save as:

C:\Users\YourName.ssh\yourppk

Create the .ssh folder if it doesn’t exist.

πŸ” Alternative (WSL / Git Bash)
puttygen yourppk.ppk -O private-openssh -o ~/.ssh/id_rsa

πŸ”’ Step 3: Fix SSH Key Permissions (Important)

Open PowerShell as Administrator:

cd $env:USERPROFILE.ssh

icacls yourppk /inheritance:r
icacls yourppk /grant:r "$($env:USERNAME):(R)"

βš™οΈ Step 4: Create SSH Config File

Create/edit:

C:\Users\YourName.ssh\config

Host
HostName
User
IdentityFile ~/.ssh/yourppk
ServerAliveInterval 60
ServerAliveCountMax 3

πŸ” Explanation

Host β†’ Friendly alias

HostName β†’ Server IP

User β†’ SSH username

IdentityFile β†’ OpenSSH key

ServerAlive* β†’ Prevent idle disconnects

πŸ§ͺ Step 5: Test SSH Connection
ssh -i $env:USERPROFILE.ssh\yourppk username@

If this works β†’ continue.

πŸ”— Step 6: Connect from VSCode

Press Ctrl+Shift+P

Select Remote-SSH: Connect to Host

Choose

Select Linux

Wait for VSCode Server installation

⏳ First connection may take 2–3 minutes.

πŸ“‚ Step 7: Open Magento Project

Open Folder

Navigate to Magento root:

/var/www/html/magento

Click OK

🧩 Step 8: Install Extensions on Remote Server

Extensions must be installed again for SSH.

Recommended Magento stack:

PHP Intelephense

GitHub Copilot

GitLens

PHP Debug

Magento 2 Snippets

Click β€œInstall in SSH: r”

πŸ›  Step 9: Magento VSCode Optimization

Create .vscode/settings.json:

{
"php.suggest.basic": false,
"intelephense.files.exclude": [
"/vendor//Tests/",
"
/pub/static/"
],
"files.watcherExclude": {
"
/var/": true,
"
/generated/": true,
"
/pub/static/": true
},
"search.exclude": {
"
/var": true,
"/generated": true,
"
/pub/static": true
}
}

πŸš€ Improves performance & IntelliSense accuracy.

πŸ”€ Working with Git in VSCode
πŸ”Ή UI Method (Fastest)

Bottom-left β†’ Click branch name β†’ Select branch

πŸ”Ή Command Palette
Git: Checkout to...

πŸ”Ή Terminal (Power User)
git fetch origin
git checkout develop
git pull origin develop

🌿 Common Git Scenarios
Checkout Remote Branch
git fetch origin
git checkout feature/contact-admin-order

Commit & Push
git add .
git commit -m "Add Google address autocomplete"
git push origin feature/contact-admin-order

πŸ” GitLens (Highly Recommended)

Features

Inline blame

File history

Branch comparison

Line-level history

Install β†’ GitLens β†’ Install in SSH

πŸ‘€ Configure Git Identity
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Verify:

git config --list

🧱 Magento-Specific Workflow

After switching branches:

composer install
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:flush

🐞 Troubleshooting
❌ SSH Connection Failed

Check IP / firewall

Verify permissions on SSH key

Test via PowerShell SSH

❌ VSCode Server Install Failed

Check disk space (df -h)

Check home directory permissions

View Remote-SSH Output

❌ Git Asking Password

Set SSH key for Git provider:

ssh-keygen -t rsa -b 4096
cat ~/.ssh/id_rsa.pub

🧠 Best Practices

Always git pull before work

Use feature branches

Commit small & often

Clear Magento cache after changes

Use Developer mode

Monitor logs:

tail -f var/log/system.log

⌨️ Useful Shortcuts
Action Shortcut
Command Palette Ctrl+Shift+P
Terminal Ctrl+`
Git Panel Ctrl+Shift+G
Quick File Ctrl+P
Multi Cursor Alt+Click
🎯 Benefits of This Setup

βœ… Full IDE on server
βœ… AI-assisted Magento coding
βœ… Zero file syncing
βœ… Faster debugging
βœ… Production-ready workflow

🧾 Summary

You now have:

πŸ”— Secure Remote SSH setup

🧠 IntelliSense & AI Copilot

🌿 Integrated Git workflows

⚑ Magento-optimized VSCode

πŸ›  Direct terminal access

This is the most efficient way to develop Magento 2 on a remote server.

Top comments (0)