8.5 KiB
VS Code SSH Setup for TrueNAS
Overview
Configure VS Code to SSH into your TrueNAS server for easy file editing and terminal access.
Prerequisites
- VS Code installed on your local machine
- Remote - SSH extension installed in VS Code
- SSH access enabled on TrueNAS
- TrueNAS IP address or hostname
Step 1: Install VS Code Extension
Install Remote - SSH Extension
- Open VS Code
- Click Extensions icon (or
Ctrl+Shift+X) - Search for: Remote - SSH
- Install the extension by Microsoft
- Reload VS Code if prompted
Extension ID: ms-vscode-remote.remote-ssh
Step 2: Enable SSH on TrueNAS (if not already enabled)
TrueNAS Scale
- Navigate to System Settings → Services
- Find SSH service
- Click Edit (pencil icon)
- Configure:
- ☑ Allow Password Authentication (initially, we'll use keys later)
- ☑ Allow TCP Forwarding
- Port: 22 (default)
- Click Save
- Start the SSH service
- ☑ Start Automatically (enable)
Step 3: Find Your TrueNAS Connection Details
Get TrueNAS IP Address
Option A: From TrueNAS UI
- Dashboard → Top right shows IP address
Option B: From Shell
ip addr show | grep inet
Get Your Username
Default admin user: admin
Or check: Credentials → Local Users
Step 4: Generate SSH Key (Recommended)
On your local Windows machine (WSL or PowerShell):
Using WSL (Recommended)
# Generate SSH key
ssh-keygen -t ed25519 -C "truenas-access"
# Default location: ~/.ssh/id_ed25519
# Press Enter to accept
# Enter passphrase (optional but recommended)
# Copy public key to TrueNAS
ssh-copy-id admin@truenas-ip
# Or manually copy:
cat ~/.ssh/id_ed25519.pub
# Then paste into TrueNAS UI
Using PowerShell (Alternative)
# Generate SSH key
ssh-keygen -t ed25519 -C "truenas-access"
# Location: C:\Users\Vince\.ssh\id_ed25519
# Copy public key
Get-Content C:\Users\Vince\.ssh\id_ed25519.pub
Add Public Key to TrueNAS
- TrueNAS UI → Credentials → Local Users
- Click Edit on your user (admin)
- Scroll to SSH Public Key
- Paste your public key
- Click Save
Step 5: Configure SSH Config File
Create/edit SSH config for easy connections.
Location
WSL: ~/.ssh/config
Windows: C:\Users\Vince\.ssh\config
Add TrueNAS Configuration
Host truenas
HostName 192.168.1.XXX # Your TrueNAS IP
User admin # Your TrueNAS username
Port 22
IdentityFile ~/.ssh/id_ed25519 # Path to your SSH key
ForwardAgent yes
ServerAliveInterval 60
ServerAliveCountMax 3
# Optional: Shorter alias
Host nas
HostName 192.168.1.XXX
User admin
IdentityFile ~/.ssh/id_ed25519
Replace: 192.168.1.XXX with your actual TrueNAS IP
Test SSH Connection
ssh truenas
# or
ssh nas
Should connect without password!
Step 6: Connect VS Code to TrueNAS
Method 1: Using Command Palette
- Open VS Code
- Press
Ctrl+Shift+P(orF1) - Type: Remote-SSH: Connect to Host
- Select truenas (or nas) from the list
- Or type:
admin@truenas-ipmanually
- Or type:
- Select platform: Linux
- VS Code will connect and install VS Code Server on TrueNAS
- Wait for connection to complete
Method 2: Using SSH Targets
- Click Remote Explorer icon in sidebar
- Under SSH Targets, you'll see configured hosts
- Click → (Connect) next to truenas
First Connection
- VS Code will install VS Code Server on TrueNAS (~100MB)
- This is a one-time setup
- May take 1-2 minutes
- You'll see progress in bottom right
Step 7: Navigate to Your Stacks Directory
Once connected:
- File → Open Folder
- Type:
/mnt/tank/stacks - Click OK
- VS Code now shows your stacks directory in explorer!
Step 8: Install Helpful Extensions (Remote)
Once connected to TrueNAS, install these extensions on the remote:
Recommended Extensions
-
Docker (
ms-azuretools.vscode-docker)- Syntax highlighting for docker-compose files
- Docker commands integration
-
YAML (
redhat.vscode-yaml)- YAML syntax validation
- Auto-completion
-
Remote - SSH: Editing Configuration Files (automatic)
- Edit SSH config directly from VS Code
Install Extensions on Remote
- Click Extensions icon
- Search for extension
- Click Install in SSH: truenas
- Extensions install on the TrueNAS server
Usage Tips
Open Terminal in VS Code
- Terminal → New Terminal (
Ctrl+`) - Opens bash terminal directly on TrueNAS
- Already in the folder you have open
Edit docker-compose Files
- Navigate to
/mnt/tank/stacks/traefik/ - Edit
docker-compose.yml - Syntax highlighting and validation included
- Save with
Ctrl+S
Run Docker Commands
# In VS Code terminal
cd /mnt/tank/stacks/traefik
docker compose up -d
docker logs traefik -f
Multiple Folders
Open workspace with multiple stack directories:
- File → Add Folder to Workspace
- Add
/mnt/tank/stacks/traefik - Add
/mnt/tank/stacks/gitea - Add
/mnt/tank/stacks/servarr - File → Save Workspace As →
truenas-stacks.code-workspace
Troubleshooting
Connection Refused
# Check SSH service is running on TrueNAS
# TrueNAS UI → System → Services → SSH → Running
# Test from terminal
ssh admin@truenas-ip
Permission Denied (publickey)
# Verify public key is added to TrueNAS
# TrueNAS UI → Credentials → Local Users → Edit → SSH Public Key
# Or enable password authentication temporarily
# TrueNAS UI → System → Services → SSH → Edit
# ☑ Allow Password Authentication
VS Code Server Installation Fails
# SSH into TrueNAS manually
ssh truenas
# Check available disk space
df -h
# VS Code Server needs ~100MB in home directory
# Clear space if needed
"Could not establish connection"
# Check VS Code settings
# Ctrl+, → Search "remote.SSH.path"
# Should point to ssh executable
# Windows: C:\Windows\System32\OpenSSH\ssh.exe
# WSL: /usr/bin/ssh
Wrong Platform Detected
If VS Code thinks TrueNAS is Windows/Mac:
Ctrl+Shift+P- Remote-SSH: Settings
- Add to
settings.json:"remote.SSH.remotePlatform": { "truenas": "linux" }
Security Best Practices
Disable Password Authentication (After Key Setup)
Once SSH keys are working:
- TrueNAS UI → System → Services → SSH → Edit
- ☐ Allow Password Authentication (uncheck)
- ☑ Login as Root with Password (uncheck)
- Click Save
Now only SSH key authentication is allowed.
Use SSH Key Passphrase
When generating keys, add a passphrase:
ssh-keygen -t ed25519 -C "truenas-access"
# Enter passphrase when prompted
Use ssh-agent to avoid typing passphrase repeatedly:
# Start ssh-agent (WSL)
eval "$(ssh-agent -s)"
# Add key
ssh-add ~/.ssh/id_ed25519
# Enter passphrase once
# Key is cached for session
Firewall Considerations
If accessing TrueNAS from outside your network:
- Don't expose SSH (port 22) directly to internet
- Use VPN (Tailscale, Wireguard) instead
- Or use SSH tunneling through a bastion host
Quick Reference
Connect to TrueNAS
# Command line
ssh truenas
# VS Code
Ctrl+Shift+P → Remote-SSH: Connect to Host → truenas
Common Paths
- Stacks:
/mnt/tank/stacks/ - Configs:
/mnt/tank/configs/ - Media:
/mnt/tank/media/
Useful VS Code Shortcuts
- Open Terminal:
Ctrl+` - Command Palette:
Ctrl+Shift+P - Open Folder:
Ctrl+K Ctrl+O - Search Files:
Ctrl+P - Save:
Ctrl+S - Close Remote: Click SSH: truenas in bottom left → Close Remote Connection
Next Steps
- Install Remote - SSH extension in VS Code
- Enable SSH service on TrueNAS
- Generate SSH key on local machine
- Add public key to TrueNAS
- Configure ~/.ssh/config with TrueNAS host
- Test SSH connection from terminal
- Connect VS Code to TrueNAS
- Open
/mnt/tank/stacksfolder in VS Code - Install Docker and YAML extensions (remote)
- Disable password authentication (after key setup)
- Create workspace for multiple stack folders