Skip to content

ssh

The ssh module manages ~/.ssh/config from Lua. Define includes, global options, and host blocks in one place; Rootbeer renders the OpenSSH config for you.

lua
local ssh = require("rootbeer.ssh")

Configure SSH

lua
ssh.config({
    includes = { "~/.ssh/private.config" },
    hosts = {
        ["*"] = {
            ForwardAgent = true,
            Compression = true,
            ControlMaster = "auto",
            ControlPath = "/tmp/ssh-%C",
            ControlPersist = true,
        },
    },
})

Boolean values are rendered as the yes/no strings OpenSSH expects.

API Reference

ssh.config(cfg)

Generates an SSH config file from structured data.

Parameterscfg: ssh.Config

hoststable<string, table<string, boolean|string|number>>optional
Host blocks. Keys are match patterns (e.g. "*", "github.com"), values are option tables.
includesstring[]optional
Paths added as Include directives at the top.
pathstringoptional
Where to write the SSH config. Defaults to "~/.ssh/config".