Skip to content

syntax: default highlighting for OpenSSH client/server config (ssh_config, sshd_config) #5112

@tredondo

Description

@tredondo

Is there an existing request for this?

  • I have searched the existing issues

Is your feature request related to a problem?

When opening /etc/ssh/sshd_config (or /etc/ssh/ssh_config, and their *.d/*.conf drop-ins) in mcedit, no syntax highlighting is applied and Options -> Syntax Highlighting shows unknown. These are among the most commonly edited system files on any Linux host, and editing them with highlighting would be nice.

The reason is that misc/syntax/Syntax.in only maps files whose name ends in .cfg, .cnf, or .conf to conf.syntax:

file ..\*\\.(?i:cfg|cnf|conf)$ Config\sfile
include conf.syntax

Since sshd_config and ssh_config use an underscore and have no extension, they fall through to the final file .\* unknown rule and get unknown.syntax.

Describe the solution you'd like

Map OpenSSH's canonical config filenames to a syntax definition by default. Two reasonable options:

  1. Minimal (preferred for a first step) — reuse the existing generic conf.syntax. In misc/syntax/Syntax.in, before the unknown catch-all, add:

    file (.*/)?ssh(d)?_config(\\..*)?$ OpenSSH\sconfig\sfile
    include conf.syntax
    

    This covers ssh_config, sshd_config, and drop-ins under ssh_config.d/ / sshd_config.d/ (e.g. 50-cloud-init.conf users typically also have a parent ssh_config to edit). It immediately fixes the "unknown" status and gives #-comments, quoted strings, numbers, and = highlighting from conf.syntax.

  2. Nicer (optional follow-up) — ship a dedicated misc/syntax/sshd.syntax (or openssh.syntax) that additionally highlights the well-known OpenSSH keywords as defined in sshd_config(5) and ssh_config(5) — e.g. Host, Match, Port, ListenAddress, PermitRootLogin, PasswordAuthentication, PubkeyAuthentication, AuthorizedKeysFile, AllowUsers, Ciphers, MACs, KexAlgorithms, HostKey, Subsystem, Include, etc., and the yes/no/prohibit-password value tokens. Then point the Syntax.in rule above at it instead of conf.syntax.

Either way, the user-visible improvement is: opening sshd_config in mcedit no longer shows "unknown" and gets at least baseline coloring out of the box.

Describe alternatives you've considered

  • Temporarily tenaming/symlinking system files to sshd.conf so the existing *.conf rule kicks is
  • Relying on the first-line regex in Syntax.in. sshd_config typically starts with # $OpenBSD: sshd_config,v ... but it's not unique enough to safely key off, so a filename rule is the right place.

Additional context

Happy to send a PR for option 1 (one-liner in Syntax.in) and if desired, a follow-up PR adding a dedicated sshd.syntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: mceditmcedit, the built-in text editorprio: mediumHas the potential to affect progress
    No fields configured for Feature.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions