Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dev Container via SSH

Why

Microsoft's Dev Containers extension is not available in VSCodium, and third-party alternatives are unstable or require extra tooling. This is a minimal SSH-based setup instead: no telemetry, no extension silently running scripts on your host. Just a Dockerfile you control and one SSH connection.

How it works

you                        docker
───                        ──────
VSCodium ·· SSH:2222 ···>  sshd
.ssh/   ····· mount ····>  .ssh/
                           /app              <─ volume
                           /app/node_modules <─ volume

Prerequisites

  1. Install Docker Desktop
  2. Install VSCodium with the Open Remote - SSH

Setup

  1. Either clone this repo or create the following files manually:

     /
     ├── .env
     ├── compose.yaml
     ├── Dockerfile
     └── entrypoint.sh
    
  2. Set APP_NAME (lowercase) and SSH_PORT in .env

    Optionally, set GIT_USER_NAME and GIT_USER_EMAIL to configure git identity globally inside the container.

  3. Update the list of Debian packages in Dockerfile if needed.

    Example: add openjdk-25-jre-headless for Java.

    nodejs is included for Node.js development - remove if not needed.

    Note: openssh-server and curl are required.

  4. Build the image:

    docker compose build --no-cache
  5. Start the container:

    docker compose up --build -d

    On first start, SSH keys are generated in ./.ssh/.

    Note: These are temporary keys used only for the Open Remote - SSH connection. You can delete ./.ssh/ and restart the container to regenerate them.

SSH Configuration

  1. Generate a personal password-protected SSH key (skip if you already have one):

    ssh-keygen -t ed25519 -C "your-key-name"
  2. Copy that key to ./.ssh/:

     ./.ssh/id_ed25519
    

    It will be used to authenticate with remote Git repositories.

    Security note: Your private SSH key is stored inside the container and accessible to all running code, including npm packages.

    A malicious package could read or exfiltrate it. A strong passphrase is your main line of defense - it will be prompted on every git push.

  3. Create ./.ssh/config - this tells SSH which key to use when connecting to a remote Git repository.

    Host codeberg.com
      HostName codeberg.com
      User git
      IdentityFile ~/.ssh/id_ed25519
    
  4. Create a dedicated SSH config file somewhere outside your projects, e.g. one level above them: C:/Projects/ssh_config. In VSCodium settings, set remote.SSH.configFile to point to it. (e.g. Cntl , and search remote.SSH.configFile)

    Add an entry:

    Host my-app
      HostName 127.0.0.1
      User user
      Port 2222
      IdentityFile <absolute-path-to-project>/.ssh/id_ed25519_container
    

    This file is separate from your local ~/.ssh/config and contains only container connections. All your projects can share it, just add a new Host block for each one.

  5. Connect via Open Remote - SSH, see https://open-vsx.org/extension/jeanp413/open-remote-ssh

    On first connect, open /app in the Explorer manually. Afterwards, directly open /app from the Recent List or use Open Recent / /app [SSH: my-app].

Workspace Initialization

  1. In the container terminal:

    chmod 600 ~/.ssh/config ~/.ssh/id_ed25519
    git init
    # Skip if GIT_USER_NAME and GIT_USER_EMAIL are set in .env
    git config --local user.name <your-name>
    git config --local user.email <your-email>
    git remote add origin <remote-repository-url>
    # Skip if starting a new project:
    git fetch
    git checkout -t origin/main
    

    Your project files will be available at /app, persisted on a Docker volume.

Volume Location (Windows)

Files in /app and /app/node_modules are stored in Docker volumes, accessible from the host at:

    \\wsl$\docker-desktop\mnt\docker-desktop-disk\data\docker\volumes\

About

A VSCodium template for Docker development via SSH • mirror of https://codeberg.org/vip-delete/remote-ssh-template

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages