Hysen Labs
Open-source project
soulteary/ssh-config avatar
soulteary

ssh-config

1 MB size, Manage your SSH config with YAML or JSON for easier maintenance. / 1 MB 大小,使用更易维护的 YAML or JSON 管理 SSH 配置文件。

71 stars5 forksGoApache-2.0
DEEP OPEN-SOURCE ANALYSIS

Manage SSH config through YAML or JSON

soulteary/ssh-config is a small command-line tool that converts between SSH config syntax and YAML or JSON while preserving every detail of the original file.

What the tool does

ssh-config is a command-line utility for managing SSH configuration files. It lets you work with more expressive YAML or JSON representations while still round-tripping back to classic ssh_config syntax. That matters because hand-edited ssh_config files get unwieldy as the number of hosts grows. The tool converts YAML or JSON into standard SSH config files and converts classic SSH config files into YAML or JSON for easier editing and review. The default mode uses a lossless v3 schema that preserves comments, ordering, repeated directives, quoting, line endings, and unknown directives. In practice this means you can reformat a config through YAML and get back bytes that keep your original structure intact except where you changed something. The previous map-based conversion and a directory scan remain available through a legacy flag for users who built workflows around the older behavior. Reading from files or standard input and writing to files or standard output are both supported. The lossless claim is the headline because it removes the usual fear that a converter will silently drop a custom directive or reorder your hosts. For a shared config reviewed in git, keeping comments and order stable means diffs stay small and meaningful, which is exactly what you want from a tool that touches infrastructure access.

Installation and usage

You can install the tool by downloading a binary for your system and CPU architecture from the GitHub release page, by using Docker, or by installing via Homebrew. Go users can install the v3 command directly. Running it without arguments exports your ssh config at the default path as lossless v3 YAML on standard output, which is a quick way to see the structured form. Linux pipes let you manipulate files in a script, and the Docker image accepts flags such as lossless, to-yaml, src, and dest to convert a file mounted from the current directory. The options section documents flags including the legacy switch, and the examples section shows editing directive fields in config.v3.yaml while unchanged lines keep their exact bytes. Because the tool auto-detects the input format, you do not have to tell it whether you are feeding YAML, JSON, or SSH config, and it tidies trailing blank lines on output. The examples also show a Docker run that mounts the working directory and writes the converted file back, which is a clean pattern for batch jobs. A second Docker example without a dest flag prints to stdout so you can inspect before committing, a habit worth keeping when the file controls how you reach your servers.

Development and quality

The repository carries codecov, Go Report Card, and CodeQL badges, which suggests the author tracks test coverage and runs static security analysis on the Go code. The development section documents dependencies, the build, and the test commands, so contributors can set up locally without guessing. Keeping the build simple fits the project's stated size of about 1 MB, which makes it practical to drop into a container or copy to a remote host. The lossless v3 schema is the headline feature because it removes the fear of losing comments or custom directives when you reformat a shared config. For teams that manage many SSH hosts, representing the config as YAML or JSON also makes templating and code review easier than editing a flat file by hand. The tool is published under the Apache-2.0 license and written in Go, so it is straightforward to vendor or extend. The CodeQL workflow in particular is a good sign for a utility that parses untrusted config text, since it catches whole classes of injection and parsing bugs before release. Combined with the small binary size, that makes the tool a low-risk addition to a system administration toolkit used across many machines. A small binary is also easier to ship to locked-down hosts with strict size limits.

Editorial conclusion

The tool is published under the Apache-2.0 license, written in Go, and is about 1 MB in size.

DEEP OPEN-SOURCE ANALYSIS

Official sources

Community notes

Community notes