Skip to main content

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):

Terminal window
brew install --cask visual-studio-code

Windows (Chocolatey):

Terminal window
choco install vscode

Linux (Ubuntu/Debian):

Terminal window
# Add Microsoft GPG key and repository
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo 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'
# Install
sudo apt update
sudo apt install code

Essential Extensions

Install these extensions for HackerOps development:

Terminal window
# Install via command line
code --install-extension ms-vscode-remote.remote-ssh
code --install-extension hashicorp.terraform
code --install-extension redhat.ansible
code --install-extension ms-python.python
code --install-extension ms-azuretools.vscode-azureterraform

Or install manually:

  1. Open VS Code
  2. Press Ctrl+Shift+X (Windows/Linux) or Cmd+Shift+X (macOS)
  3. 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

  1. Open VS Code Remote Panel:

    • Press F1 or Ctrl+Shift+P (Cmd+Shift+P on macOS)
    • Type β€œRemote-SSH: Open SSH Configuration File”
    • Select your user config file (usually ~/.ssh/config)
  2. Add Your VM Configuration: Replace YOUR_VM_IP with your actual VM IP address:

    Host hackerops-vm
    HostName YOUR_VM_IP
    User vagrant
    Port 22
  3. Save the Configuration File

2. Connect to Your VM

  1. Open Remote Connection:

    • Click the green >< icon in the bottom-left corner
    • Select β€œConnect to Host…”
    • Choose β€œhackerops-vm” from the list
  2. First Connection:

    • Click β€œContinue” when prompted about the SSH fingerprint
    • Enter password: vagrant (for pre-configured VMs)
  3. 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:

Terminal window
# Check versions of pre-installed tools
terraform --version
ansible --version
git --version
# Create a test workspace
mkdir ~/hackerops-labs
cd ~/hackerops-labs

Local Development (Optional)

For local work (when not using SSH):

  1. Create a Workspace:

    • File β†’ Open Folder
    • Create or select ~/hackerops-labs
    • This will be your local lab directory
  2. 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, password vagrant

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.