Write the SSH block
$ grim server:dev:ssh-config dev1
VS Code Remote-SSH picks its targets from ~/.ssh/config, and nobody wants to type dev@203.0.113.10 every morning. Once a box exists, grim server:dev:ssh-config prints the block that gives it a short name. Paste it once per machine.
Usage
$ grim server:dev:ssh-config dev1 # by alias
$ grim server:dev:ssh-config 203.0.113.10 # the address works as wellRun it from anywhere. The argument is the address or alias of a server in your ~/.grim/servers.json, which means a server you set up from this machine.
Arguments and options
Print a ~/.ssh/config block for connecting to a dev VPS
Usage
grim server:dev:ssh-config <host>Arguments
| Argument | Description |
|---|---|
host |
Dev server host or alias (required) |
What it actually does
- Looks the server up in
~/.grim/servers.json. It does not connect to anything. - Prints a
Hostblock. The name is the alias with-devadded, sodev1becomesdev1-dev. The block setsHostNameto the server's address,User dev,StrictHostKeyChecking accept-new, and a keep-alive every 30 seconds that gives up after three missed replies. - Prints the two commands that use it:
ssh dev1-dev, andcode --remote ssh-remote+dev1-dev /home/dev/projects/<project>.
Nothing is written to ~/.ssh/config. The output starts with a comment line and ends with the two commands, so copy the block itself, from Host to ServerAliveCountMax.
Pitfalls
The block names no key
SSH offers your default keys. When the key you gave to grim server:dev:keys lives somewhere else, add IdentityFile ~/.ssh/<key> to the block by hand.
A colleague cannot run it
Unknown host "dev1". means the server is not in that person's servers.json, and it will not be unless they set the box up themselves. Run the command for them and send the block. It holds an address and a user name, nothing secret.
After it finishes
With the block pasted and a key on the box, the connection is one command.
$ ssh dev1-dev
$ code --remote ssh-remote+dev1-dev /home/dev/projects/shopThe project path and the rest of what a developer needs are on the card that grim server:dev:info prints.
Related spells
grim server:dev:keys
Let developers onto the box
List, add and remove the labelled SSH keys that let developers log in as the shared dev user of a dev box.
grim server:dev:info
Show a project's dev card
Print the URLs, SSH and VS Code commands, database credentials and container states of a project on a dev box.
grim server:dev:setup
Raise a shared dev box
Turn a bare VPS or LAN machine into a shared development server with Docker, Traefik, one dev user and grim itself.
Recipes that use it
Set up a dev box for a client
Raise a shared development server, give it a registry token, put the first project on it, let developers in by key, hand over the access card, and later take a developer or a project off again.
Work on a client's dev box
Send your public key to the operator, paste the SSH block they send back, attach your editor to the project on the box, reload the stack after a change to .env, and open the database from there.
Curses it can raise
kex_exchange_identification: Connection closed by remote host
sshd MaxStartups drops connections when a parallel sync opens too many at once.