Visual Studio Code Setup
Visual Studio Code Setup
VS Code is your primary development environment for HackerOps labs. Youβll use it to edit code locally and connect to your Ubuntu environment via SSH for seamless remote development.
Tip
Why VS Code: Built-in SSH support, excellent Terraform/Ansible extensions, and integrated terminal make it perfect for infrastructure automation work.
Installation
Download from Website
Download VS Code - Available for Windows, macOS, and Linux
Package Manager Installation
macOS (Homebrew):
brew install --cask visual-studio-code
Windows (Chocolatey):
choco install vscode
Linux (Ubuntu/Debian):
# Add Microsoft GPG key and repositorywget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpgsudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
# Installsudo apt updatesudo apt install code
Essential Extensions
Install these extensions for HackerOps development:
# Install via command linecode --install-extension ms-vscode-remote.remote-sshcode --install-extension hashicorp.terraformcode --install-extension redhat.ansiblecode --install-extension ms-python.pythoncode --install-extension ms-azuretools.vscode-azureterraform
Or install manually:
- Open VS Code
- Press
Ctrl+Shift+X
(Windows/Linux) orCmd+Shift+X
(macOS) - Search for and install:
- Remote - SSH (Essential for connecting to VMs)
- HashiCorp Terraform (Syntax highlighting and validation)
- Ansible (Playbook support and IntelliSense)
- Python (Required for Ansible)
- Azure Terraform (Azure-specific Terraform support)
SSH Remote Development Setup
Info
Prerequisite: You need a running Ubuntu VM with an IP address. See the Ubuntu Setup Guide first.
1. Configure SSH Connection
-
Open VS Code Remote Panel:
- Press
F1
orCtrl+Shift+P
(Cmd+Shift+P
on macOS) - Type βRemote-SSH: Open SSH Configuration Fileβ
- Select your user config file (usually
~/.ssh/config
)
- Press
-
Add Your VM Configuration: Replace
YOUR_VM_IP
with your actual VM IP address:Host hackerops-vmHostName YOUR_VM_IPUser vagrantPort 22 -
Save the Configuration File
2. Connect to Your VM
-
Open Remote Connection:
- Click the green
><
icon in the bottom-left corner - Select βConnect to Hostβ¦β
- Choose βhackerops-vmβ from the list
- Click the green
-
First Connection:
- Click βContinueβ when prompted about the SSH fingerprint
- Enter password:
vagrant
(for pre-configured VMs)
-
Open Your Workspace:
- Click βOpen Folderβ in the Welcome tab
- Choose
/home/vagrant
or create a new project folder - Click βOKβ
Tip
Pro Tip: Once connected, you can open a terminal (Ctrl+``
or Terminal β New Terminal) to run commands directly on your Ubuntu VM.
3. Verify Setup
After connecting, verify your environment:
# Check versions of pre-installed toolsterraform --versionansible --versiongit --version
# Create a test workspacemkdir ~/hackerops-labscd ~/hackerops-labs
Local Development (Optional)
For local work (when not using SSH):
-
Create a Workspace:
- File β Open Folder
- Create or select
~/hackerops-labs
- This will be your local lab directory
-
Open Integrated Terminal:
- Terminal β New Terminal
- This opens at your workspace root
Troubleshooting
SSH Connection Issues
Connection refused:
- Verify VM is running and IP address is correct
- Check if SSH service is running:
sudo systemctl status ssh
Permission denied:
- Verify username and password
- For pre-configured VMs: username
vagrant
, passwordvagrant
Canβt find config file:
- Create
~/.ssh/config
manually if it doesnβt exist - On Windows:
C:\Users\[username]\.ssh\config
Extension Issues
Extensions not loading:
- Install extensions on the SSH host (not locally)
- VS Code will prompt you to install extensions on the remote
Terraform/Ansible not working:
- Verify tools are installed:
terraform --version
,ansible --version
- Check VS Code terminal is using the correct environment
Caution
Important: When using SSH, install extensions on the remote server, not locally. VS Code will show separate extension tabs for local and remote.