Expand description
Editing of /etc/ssh/sshd_config for access-control directives.
This reuses the lossless ast::ConfigAst (which already handles Match
blocks, Include, comments, and whitespace faithfully) to provide focused
read/edit operations for the user-access directives Toride cares about:
AllowUsers and DenyUsers.
Writes are privileged (the file is root-owned) and go through
toride_ssh_core::run_privileged, which validates the result with
sshd -t and keeps a .bak backup before installing — a malformed
sshd_config would lock the user out of SSH, so an invalid config is never
written.
All access here is restricted to global directives (those outside any
Match block). Match-scoped directives are intentionally left untouched
— editing them blindly is dangerous, and global scope is what we expose in
the UI.
Functions§
- add_
user_ to_ allow - Add
userto the globalAllowUsersdirective. - add_
user_ to_ deny - Add
userto the globalDenyUsersdirective. Idempotent. - directive_
has_ patterns - Returns
trueif any global<key>directive contains pattern tokens. - edit
- Load, mutate, and save
/etc/ssh/sshd_configin one call. - get_
allow_ groups - The current global
AllowGroupslist (ignoringMatch-scoped directives). - get_
allow_ users - The current global
AllowUserslist (ignoringMatch-scoped directives). - get_
deny_ groups - The current global
DenyGroupslist (ignoringMatch-scoped directives). - get_
deny_ users - The current global
DenyUserslist (ignoringMatch-scoped directives). - has_
pattern_ tokens - Returns
trueifvaluecontains any OpenSSH pattern tokens. - load
- Load and parse
/etc/ssh/sshd_configinto a lossless AST. - remove_
user_ from_ allow - Remove
userfrom the globalAllowUsersdirective. - remove_
user_ from_ deny - Remove
userfrom the globalDenyUsersdirective, deleting the directive if it becomes empty. - save
- Serialize the AST and install it as
/etc/ssh/sshd_configvia a privileged operation (validation + backup + atomic install).