Guia prático para configuração do ambiente e execução dos laboratórios.
📝 Convenção de Nomes: Ao longo deste manual, usamos <seu-nome>-nodegoat
como exemplo de nome para o repositório pessoal (ex: joao-nodegoat
, maria-nodegoat
). Você pode escolher o nome que preferir para seu repositório, mas recomendamos seguir este padrão para facilitar a identificação.
Se você usa Windows, configure o WSL 2 ANTES de continuar.
👉 Vá para: Apêndice A: Configuração do WSL 2
Após configurar, volte para a Seção 1.
wsl
Todos os comandos e ferramentas devem ser executados dentro do terminal WSL (Ubuntu), não no Windows nativo.
cd ~
Não trabalhe nos diretórios montados do Windows (/mnt/c/
), pois isso causa problemas de performance e permissões. Clone os repositórios diretamente no home do WSL (~
).
- Instalação Inicial
- Configuração do GitHub
- Setup do Repositório
- Pre-commit Hooks
- 4.1 Copiar Configurações
- 4.2 Ativar Hooks
- 4.3 Testar Hooks
- 4.4 Desinstalar Hooks
- Kubernetes Local
- 5.1 Copiar Configurações K8s
- 5.2 Deploy Cluster
- 5.3 Verificar Cluster
- GitHub Actions Runner
- 6.1 Criar GitHub PAT
- 6.2 Deploy Runner
- 6.3 Verificar Instalação
- Workflow 00 - Debug
- 7.1 Copiar Workflow
- 7.2 Criar PR de Teste
- 7.3 Verificar Execução
- Workflow 01 - Secret Scanning
- Workflow 02 - SCA
- 9.1 Deploy Dependency Track
- 9.2 Configurar API Key
- 9.3 Copiar Workflow
- 9.4 Testar SCA
- Workflow 03 - SAST
- 10.1 Deploy SonarQube
- 10.2 Gerar Tokens no SonarQube
- 10.3 Copiar Workflow
- 10.4 Testar SAST
- Workflow 04 - Container Scanning
- 11.1 Criar Conta Docker Hub
- 11.2 Criar Access Token
- 11.3 Criar Repositório Docker Hub
- 11.4 Configurar Secrets GitHub
- 11.5 Deploy ArcherySec
- 11.6 Copiar Workflow
- 11.7 Testar Container Scanning
- Workflow 05 - IaC Scanning
- 12.1 Configurar ArcherySec API Key
- 12.2 Copiar Workflow
- 12.3 Testar IaC Scanning
- Workflow 06 - Build e Deploy
- Referência Rápida
- Apêndice A: Configuração do WSL 2
Para facilitar os comandos ao longo do laboratório, crie variáveis com os caminhos dos repositórios:
# Repositório do instrutor (já existe)
export INSTRUCTOR_REPO=~/nodegoat
# Seu repositório pessoal (será criado na seção 2.2)
# Substituir <seu-nome>-nodegoat pelo nome escolhido
export STUDENT_REPO=~/<seu-nome>-nodegoat
# Exemplo: export STUDENT_REPO=~/joao-nodegoat
# Para tornar permanente, adicionar ao ~/.bashrc ou ~/.zshrc:
echo 'export INSTRUCTOR_REPO=~/nodegoat' >> ~/.bashrc
echo 'export STUDENT_REPO=~/<seu-nome>-nodegoat' >> ~/.bashrc
source ~/.bashrc
# macOS (se usar zsh):
echo 'export INSTRUCTOR_REPO=~/nodegoat' >> ~/.zshrc
echo 'export STUDENT_REPO=~/<seu-nome>-nodegoat' >> ~/.zshrc
source ~/.zshrc
Todos os comandos a seguir usarão $INSTRUCTOR_REPO
e $STUDENT_REPO
.
Nota: O repositório pessoal será criado no GitHub na Seção 2.2 e clonado localmente na Seção 3.1.
# Verificar se já está instalado
brew --version
# Se não estiver instalado:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Seguir instruções na tela para adicionar ao PATH
# macOS
brew install just
# Linux/WSL
sudo apt update && sudo apt install -y just
macOS:
- Baixar Docker Desktop para Mac
- Instalar e iniciar
Windows:
- Baixar Docker Desktop para Windows
- Durante instalação: marcar "Use WSL 2 instead of Hyper-V"
- Após instalação:
- Abrir Docker Desktop
- Settings → Resources → WSL Integration
- Habilitar integração com Ubuntu
Linux:
Documentação oficial: https://docs.docker.com/engine/install/ubuntu/
# Remover versões antigas (se houver)
sudo apt remove docker docker-engine docker.io containerd runc
# Instalar dependências
sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release
# Adicionar chave GPG oficial do Docker
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Adicionar repositório Docker
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Instalar Docker Engine
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Adicionar usuário ao grupo docker
sudo usermod -aG docker $USER
newgrp docker
# Iniciar serviço
sudo systemctl enable docker
sudo systemctl start docker
Verificar:
docker --version
docker compose version
# Ir para o diretório home
cd ~
# Clonar repositório do instrutor (será o $INSTRUCTOR_REPO)
git clone https://github.com/cesar-devsecops-2025/nodegoat
cd nodegoat
# Ou usar a variável:
# git clone https://github.com/cesar-devsecops-2025/nodegoat $INSTRUCTOR_REPO
# cd $INSTRUCTOR_REPO
# Instalar TODAS as ferramentas automaticamente
just setup
O que just setup
instala:
- Git
- kubectl (Kubernetes CLI)
- pre-commit (hooks framework)
- kind (Kubernetes in Docker)
- helm (package manager)
- kubectx/kubens (context switcher)
- k9s (TUI manager)
# Se pre-commit não for encontrado
source ~/.bashrc
# ou reiniciar terminal
Configurar Git:
git config --global user.name "Seu Nome"
git config --global user.email "seu@email.com"
- GitHub → Settings → Organizations → New organization
- Organization Settings → Actions → General
- Selecionar: "Allow all actions and reusable workflows"
- Na organização criada, clicar em "New repository"
- Nome:
<seu-nome>-nodegoat
(ex:joao-nodegoat
) - Visibilidade: Public
- Pode inicializar com README (opcional), NÃO adicionar .gitignore ou licença
- Repository Settings → Code security and analysis
- Habilitar Dependency graph
- NÃO habilitar (vamos usar ferramentas customizadas):
- Dependabot alerts → Usaremos Dependency Track
- Dependabot security updates → Gerenciamento manual de dependências
- Secret scanning push protection → Usaremos Gitleaks no pre-commit e CI/CD
# Voltar ao diretório home
cd ~
# Clonar seu repositório pessoal (será o $STUDENT_REPO)
git clone https://github.com/<sua-org>/<seu-nome>-nodegoat
# Exemplo: git clone https://github.com/cesar-devsecops-joao/joao-nodegoat
# Ou usar a variável para especificar o diretório local:
# git clone https://github.com/<sua-org>/<seu-nome>-nodegoat $STUDENT_REPO
# Do diretório do instrutor
cd $INSTRUCTOR_REPO
# Copiar arquivos para seu repo
cp -r app $STUDENT_REPO/
cp -r config $STUDENT_REPO/
cp package.json package-lock.json server.js Dockerfile docker-compose.yaml .dockerignore .gitignore .justfile $STUDENT_REPO/
# Ir para seu repo
cd $STUDENT_REPO
# Commit inicial
git add .
git commit -m "feat: initial NodeGoat setup"
git push origin main
# Subir app e MongoDB
just start
# Acessar no browser: http://localhost:4000
# Popular banco: http://localhost:4000/tutorial/db-reset
# Parar
just stop
# Do repo do instrutor
cd $INSTRUCTOR_REPO
cp .pre-commit-config.yaml $STUDENT_REPO/
mkdir -p $STUDENT_REPO/scripts
cp scripts/DAST_zap.sh scripts/npm_audit_summary.sh scripts/zap.context $STUDENT_REPO/scripts/
# Ir para seu repo
cd $STUDENT_REPO
git add .
git commit -m "feat: add pre-commit hooks configuration"
git push origin main
pre-commit install
# Teste - Secret Scanning
echo 'GITLAB_TOKEN="glpat-1234567890abcdefghij"' > .env
git add .env
git commit -m "test: secret detection"
# ❌ Deve falhar (Gitleaks detecta)
# Limpar
git reset HEAD~1 && rm .env
pre-commit uninstall
# Do repo do instrutor
cd $INSTRUCTOR_REPO
cp kind-config.yaml $STUDENT_REPO/
mkdir -p $STUDENT_REPO/k8s/metrics-server
cp -r k8s/metrics-server/* $STUDENT_REPO/k8s/metrics-server/
# Ir para seu repo
cd $STUDENT_REPO
git add kind-config.yaml k8s/
git commit -m "feat: add Kubernetes configuration"
git push origin main
# No repo do instrutor (tem justfile completo)
cd $INSTRUCTOR_REPO
just deploy-kind-cluster
# Verificar nodes
kubectl get nodes
# Verificar metrics-server
kubectl get pods -n kube-system | grep metrics-server
# Verificar ferramentas instaladas
kubectl version --client
kind version
helm version
kubectx --version
kubens --version
k9s version
- GitHub → Settings → Developer settings
- Personal access tokens → Tokens (classic)
- Generate new token (classic)
- Scopes:
repo
,admin:org
- Copiar token gerado (será usado como
GITHUB_PAT
no próximo passo)
# No repo do instrutor
cd $INSTRUCTOR_REPO
# Criar arquivo com credenciais
# Substitua:
# <sua-org> = nome da organização criada na seção 2.1
# ghp_seu_token_aqui = token copiado na seção 6.1
cat > .env.secrets << 'EOF'
GITHUB_CONFIG_URL=https://github.com/<sua-org>
GITHUB_PAT=ghp_seu_token_aqui
EOF
# Deploy Actions Runner Controller
just setup-github-runners
# Verificar pods
kubectl get pods -n arc-systems
kubectl get pods -n arc-runners
# Verificar runner scale set
kubectl get runnerscaleset -n arc-runners
No GitHub:
- Organization Settings → Actions → Runners
- Deve aparecer:
arc-runner-set
(Active) ⚠️ IMPORTANTE - Habilitar para repositórios públicos:- Na mesma página (Organization Settings → Actions → Runners)
- Clicar na aba "Runner groups"
- Clicar no grupo "Default"
- Marcar a opção "Allow public repositories"
- Clicar em "Save group" para salvar alterações
# Do repo do instrutor
cd $INSTRUCTOR_REPO
mkdir -p $STUDENT_REPO/.github/workflows/
cp .github/workflows/00-debug.yaml $STUDENT_REPO/.github/workflows/
# Ir para seu repo
cd $STUDENT_REPO
git add .github/
git commit -m "ci: add debug workflow"
git push origin main
git checkout -b test-runner-connectivity
echo "# Testing runners" > TEST.md
git add TEST.md
git commit -m "test: verify runner connectivity"
git push origin test-runner-connectivity
No GitHub:
- Pull Requests → Abrir PR criado
- Aba "Checks"
- Confirmar 2 jobs em paralelo:
- ✅ Debug - connectivity
- ✅ Debug - docker-dind
Troubleshooting:
connectivity
falha → Problema no ARC/runnerdocker-dind
falha → VerificarcontainerMode.type="dind"
Limpar:
- Fechar PR (não merge)
- Deletar branch:
git branch -D test-runner-connectivity
- Acessar https://gitleaks.io/ e criar conta
- Dashboard → Licenses
- Solicitar GitHub organization license
- Copiar licença (string
eyJ...
)
- Repository Settings → Secrets and variables → Actions
- New repository secret
- Name:
GITLEAKS_LICENSE
- Value: colar licença
- Add secret
# Do repo do instrutor
cd $INSTRUCTOR_REPO
# Remover workflow anterior
rm $STUDENT_REPO/.github/workflows/00-debug.yaml
# Copiar workflow de secret scanning
cp .github/workflows/01-secret-scanning.yaml $STUDENT_REPO/.github/workflows/
# Ir para seu repo
cd $STUDENT_REPO
git add .github/workflows/
git commit -m "ci: remove debug workflow and add secret scanning"
git push origin main
# Criar branch de teste
git checkout -b test-secret-scanning
# Opção 1: Copiar chave privada (simular leak)
cp artifacts/cert/server.key leaked-private-key.pem
# Opção 2: Adicionar secrets de teste
cat > test-secrets.env << 'EOF'
AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE"
GITHUB_TOKEN="ghp_1234567890abcdefghijklmnopqrstuvwxyz"
DATABASE_PASSWORD="super-secret-password-123"
EOF
git add leaked-private-key.pem test-secrets.env
git commit -m "test: add secrets for scanning demo"
git push origin test-secret-scanning
Verificar resultados:
- Abrir PR no GitHub
- Aba "Checks": Verificar Trivy e Gitleaks
- Trivy: Categoriza por severidade (CRITICAL, HIGH, MEDIUM, LOW)
- Gitleaks: Reporta como WARNING
- Aba "Security" → "Code scanning": Ver anotações inline com tipo de secret detectado
Limpar:
- Fechar PR sem merge
- Deletar branch:
git branch -D test-secret-scanning
# No repo do instrutor
cd $INSTRUCTOR_REPO
just start-dependency-track
- Acesso: http://localhost:8081
- Login:
admin
/admin
- Aguardar inicialização (3-5 minutos)
No Dependency Track:
- Administration → Access Management → Teams
- Selecionar team "Automation"
- Aba "API Keys" → "+ Create API Key"
- Copiar API Key
No GitHub:
- Repository Settings → Secrets and variables → Actions
- New repository secret
- Name:
DEPENDENCYTRACK_APIKEY
- Value: colar API Key
- Add secret
# Do repo do instrutor
cd $INSTRUCTOR_REPO
# Remover workflow anterior
rm $STUDENT_REPO/.github/workflows/01-secret-scanning.yaml
# Copiar workflow de SCA
cp .github/workflows/02-sca.yaml $STUDENT_REPO/.github/workflows/
# Ir para seu repo
cd $STUDENT_REPO
git add .github/workflows/
git commit -m "ci: remove secret scanning workflow and add SCA"
git push origin main
# Criar branch de teste
git checkout -b test-sca
# Adicionar dependência vulnerável ao package.json
# Encontrar a linha "dependencies": { e adicionar:
# "axios": "0.21.1",
# Ou usar sed (Linux/macOS):
sed -i.bak '/"dependencies": {/a\
"axios": "0.21.1",' package.json
# Gerar package-lock.json
npm install
git add package.json package-lock.json
git commit -m "test: add vulnerable dependency for SCA demo"
git push origin test-sca
Criar PR e verificar:
No Dependency Track (http://localhost:8081):
- Projeto "app" criado automaticamente
- Overview: Métricas resumidas, risk score
- Components: Dependências diretas e transitivas
- Audit Vulnerabilities: CVEs encontrados
- Ver CVSS score (severidade técnica)
- Ver EPSS score (probabilidade de exploração)
No GitHub:
- Aba "Security" → "Code scanning": Alertas do Trivy
- Aba "Insights" → "Dependency graph": Árvore de dependências
Limpar:
- Fechar PR e deletar branch
- Reverter package.json se necessário
# Do repo do instrutor
cd $INSTRUCTOR_REPO
# Parar Dependency Track
just stop-dependency-track
# Copiar configuração SonarQube
mkdir -p $STUDENT_REPO/k8s/sonarqube
cp k8s/sonarqube/sonarqube-values.yaml $STUDENT_REPO/k8s/sonarqube/
cd $STUDENT_REPO
git add k8s/sonarqube/
git commit -m "feat: add SonarQube Helm values configuration"
git push origin main
# Deploy SonarQube
cd $INSTRUCTOR_REPO
just start-sonarqube
- Acesso: http://localhost:9000
- Login:
admin
/admin
(trocar senha no primeiro acesso)
Token 1 - Global Analysis Token:
- My Account → Security
- Generate Tokens → Token name:
github-actions-token
- Type: Global Analysis Token
- Expires in: No expiration
- Generate → Copiar token
Token 2 - User Token:
- Mesma página (My Account → Security)
- Token name:
github-actions-user-token
- Type: User Token
- Expires in: No expiration
- Generate → Copiar token
Configurar no GitHub:
- Repository Settings → Secrets and variables → Actions
- Criar dois secrets:
- Name:
SONAR_TOKEN
| Value: Global Analysis Token - Name:
SONAR_USER_TOKEN
| Value: User Token
- Name:
# Do repo do instrutor
cd $INSTRUCTOR_REPO
# Remover workflow anterior
rm $STUDENT_REPO/.github/workflows/02-sca.yaml
# Copiar workflow de SAST
cp .github/workflows/03-sast.yaml $STUDENT_REPO/.github/workflows/
# Ir para seu repo
cd $STUDENT_REPO
git add .github/workflows/
git commit -m "ci: remove SCA workflow and add SAST"
git push origin main
# Criar branch de teste
git checkout -b test-sast
# Copiar arquivo com vulnerabilidades intencionais
cp app/data/allocations-dao.js app/data/teste.js
git add app/data/teste.js
git commit -m "test: add vulnerable code for SAST demonstration"
git push origin test-sast
Criar PR e verificar:
No GitHub:
- Abrir PR da branch
test-sast
- Aba "Security" → "Code scanning"
- Filtrar por Tool: "SonarQube"
- Ver anotações inline no código
No SonarQube (http://localhost:9000):
- Projeto "app" criado
- Métricas: Security, Reliability, Maintainability
- Security Hotspots
- Issues: NoSQL Injection, Code Smells, Complexidade
Limpar:
- Fechar PR e deletar branch
- Acessar https://hub.docker.com/signup
- Criar conta gratuita
- Verificar email
- Login: https://hub.docker.com
- Avatar → Account Settings → Security
- New Access Token
- Description: "GitHub Actions - NodeGoat DevSecOps"
- Access permissions: Read, Write, Delete
- Generate → Copiar token
- Repositories → Create Repository
- Name:
nodegoat
- Visibility: Public
- Create
Secret:
- Repository Settings → Secrets and variables → Actions
- New repository secret
- Name:
DOCKERHUB_TOKEN
- Value: colar Access Token
- Add secret
Variable:
- Aba "Variables" → New repository variable
- Name:
DOCKERHUB_USERNAME
- Value: seu username Docker Hub
- Add variable
# Do repo do instrutor
cd $INSTRUCTOR_REPO
# Copiar manifestos ArcherySec
mkdir -p $STUDENT_REPO/k8s/archery
cp -r k8s/archery/* $STUDENT_REPO/k8s/archery/
cd $STUDENT_REPO
git add k8s/archery/
git commit -m "feat: add ArcherySec Kubernetes manifests"
git push origin main
# Parar SonarQube e subir ArcherySec
cd $INSTRUCTOR_REPO
just stop-sonarqube
just start-archerysec
# Aguardar pods Ready
kubectl get pods -n archerysec -w
- Acesso: http://localhost:8083
- Login:
admin@intra.local
/admin
# Do repo do instrutor
cd $INSTRUCTOR_REPO
# Remover workflow anterior
rm $STUDENT_REPO/.github/workflows/03-sast.yaml
# Copiar workflow de container scanning
cp .github/workflows/04-container-scanning.yaml $STUDENT_REPO/.github/workflows/
# Ir para seu repo
cd $STUDENT_REPO
git add .github/workflows/
git commit -m "ci: remove SAST workflow and add container scanning"
git push origin main
# Criar PR de teste
git checkout -b test-container-scanning
echo "test" >> README.md
git add README.md
git commit -m "test: trigger container scanning"
git push origin test-container-scanning
Verificar:
- GitHub Actions: Build multi-plataforma
- Docker Hub: Imagem publicada
- Code Scanning: Vulnerabilidades e licenças
Limpar:
- Fechar PR e deletar branch
No ArcherySec (http://localhost:8083):
- Login:
admin@intra.local
/admin
- Settings → Access Keys
- Generate New Key → Copiar token
No GitHub:
- Repository Settings → Secrets and variables → Actions
- New repository secret
- Name:
ARCHERYSEC_APIKEY
- Value: colar token
- Add secret
# Do repo do instrutor
cd $INSTRUCTOR_REPO
# Remover workflow anterior
rm $STUDENT_REPO/.github/workflows/04-container-scanning.yaml
# Copiar workflow de IaC scanning
cp .github/workflows/05-iac-scanning.yaml $STUDENT_REPO/.github/workflows/
# Ir para seu repo
cd $STUDENT_REPO
git add .github/workflows/
git commit -m "ci: remove container scanning and add IaC scanning"
git push origin main
# Criar PR de teste
git checkout -b test-iac-scanning
echo "test" >> README.md
git add README.md
git commit -m "test: trigger IaC scanning"
git push origin test-iac-scanning
Verificar:
- GitHub Actions: Trivy e Checkov scanning
- ArcherySec: Resultados centralizados
Limpar:
- Fechar PR e deletar branch
# Do repo do instrutor
cd $INSTRUCTOR_REPO
# Copiar manifestos NodeGoat
mkdir -p $STUDENT_REPO/k8s/nodegoat
cp -r k8s/nodegoat/* $STUDENT_REPO/k8s/nodegoat/
cd $STUDENT_REPO
git add k8s/nodegoat/
git commit -m "feat: add NodeGoat Kubernetes manifests"
git push origin main
# Parar ArcherySec e subir NodeGoat
cd $INSTRUCTOR_REPO
just stop-archerysec
just start-nodegoat-k8s
# Aguardar pods Ready
kubectl get pods -n nodegoat -w
- Acesso: http://localhost:8084
# macOS - Copiar para clipboard
kind get kubeconfig --name devsecops | \
sed 's|https://127.0.0.1:[0-9]*|https://kubernetes.default.svc|g' | \
base64 | pbcopy
# Linux - Copiar para clipboard
kind get kubeconfig --name devsecops | \
sed 's|https://127.0.0.1:[0-9]*|https://kubernetes.default.svc|g' | \
base64 -w 0 | xclip -selection clipboard
No GitHub:
- Repository Settings → Secrets and variables → Actions
- New repository secret
- Name:
KUBECONFIG
- Value: colar output base64
- Add secret
# Do repo do instrutor
cd $INSTRUCTOR_REPO
# Remover workflow anterior
rm $STUDENT_REPO/.github/workflows/05-iac-scanning.yaml
# Copiar workflow de build/deploy
cp .github/workflows/06-build-deploy.yaml $STUDENT_REPO/.github/workflows/
# Ir para seu repo
cd $STUDENT_REPO
git add .github/workflows/
git commit -m "ci: remove IaC scanning and add build/deploy"
git push origin main
# Criar PR de teste
git checkout -b test-build-deploy
echo "test" >> README.md
git add README.md
git commit -m "test: trigger build and deploy"
git push origin test-build-deploy
Verificar:
- GitHub Actions: Build → Deploy staging
- Docker Hub: Imagem com tag da branch
- Kubernetes:
kubectl get pods -n nodegoat
- App: http://localhost:8084
Fazer merge:
- Aprovar e merge PR para main
- Verificar build com tag
latest
Just:
just --list # Comandos
just setup # Instalar ferramentas
just start # Subir app
just stop # Parar app
just deploy-kind-cluster # Criar K8s
Kubernetes:
kubectl get nodes # Nodes
kubectl get pods -n <namespace> # Pods
kubectl logs -n <namespace> <pod> # Logs
kubectl get runnerscaleset -n arc-runners # Runners
kubectx # Clusters
kubens # Namespaces
k9s # TUI
Git:
git status # Status
git add . # Add
git commit -m "msg" # Commit
git push origin <branch> # Push
git checkout -b <branch> # Nova branch
Docker:
docker ps # Containers
docker compose logs -f # Logs
docker compose up -d # Subir
docker compose down # Parar
Navegação:
cd $INSTRUCTOR_REPO # Repo instrutor
cd $STUDENT_REPO # Seu repo
pwd # Diretório atual
- Windows 10: Versão 2004+ (Build 19041+)
- Windows 11: Qualquer versão
- Permissões de Administrador
Verificar versão:
Win + R
- Digite
winver
- Verificar requisitos
PowerShell como Admin:
wsl --install
Isso instala:
- Windows Subsystem for Linux
- Virtual Machine Platform
- Kernel Linux
- Ubuntu (padrão)
Restart-Computer
- Abrir "Ubuntu" no menu Iniciar
- Aguardar inicialização (demora na 1ª vez)
- Criar usuário e senha
wsl -l -v
Deve mostrar:
NAME STATE VERSION
* Ubuntu Running 2
Se VERSION = 1:
wsl --set-version Ubuntu 2
wsl --set-default-version 2
sudo apt update && sudo apt upgrade -y
wsl # Iniciar Ubuntu
wsl -l -v # Listar distribuições
wsl --shutdown # Desligar WSL
wsl --terminate Ubuntu # Desligar Ubuntu
Windows → Ubuntu:
- Explorador:
\\wsl$\Ubuntu\home\seuusuario
Ubuntu → Windows:
cd /mnt/c/Users/SeuUsuario # Drive C:
Erro "requires update":
Erro "Virtualization not enabled":
- BIOS → Habilitar VT-x/AMD-V
Instalação trava:
wsl --shutdown
Após configurar WSL 2: Voltar para Seção 1