@@ -16,8 +16,8 @@ use tracing::{debug, info, warn};
1616use crate :: args:: { DefaultShell , Setting } ;
1717use crate :: error:: SshdConfigError ;
1818use crate :: inputs:: { CommandInfo , SshdCommandArgs } ;
19- use crate :: metadata:: { SSHD_CONFIG_HEADER , SSHD_CONFIG_HEADER_VERSION , SSHD_CONFIG_HEADER_WARNING } ;
20- use crate :: util:: { build_command_info, get_default_sshd_config_path, invoke_sshd_config_validation} ;
19+ use crate :: metadata:: { REPEATABLE_KEYWORDS , SSHD_CONFIG_HEADER , SSHD_CONFIG_HEADER_VERSION , SSHD_CONFIG_HEADER_WARNING } ;
20+ use crate :: util:: { build_command_info, format_sshd_value , get_default_sshd_config_path, invoke_sshd_config_validation} ;
2121
2222/// Invoke the set command.
2323///
@@ -114,10 +114,24 @@ fn set_sshd_config(cmd_info: &CommandInfo) -> Result<(), SshdConfigError> {
114114 let mut config_text = SSHD_CONFIG_HEADER . to_string ( ) + "\n " + SSHD_CONFIG_HEADER_VERSION + "\n " + SSHD_CONFIG_HEADER_WARNING + "\n " ;
115115 if cmd_info. clobber {
116116 for ( key, value) in & cmd_info. input {
117- if let Some ( value_str) = value. as_str ( ) {
118- writeln ! ( & mut config_text, "{key} {value_str}" ) ?;
117+ let key_lower = key. to_lowercase ( ) ;
118+
119+ // Handle repeatable keywords - write multiple lines
120+ if REPEATABLE_KEYWORDS . contains ( & key_lower. as_str ( ) ) {
121+ if let Value :: Array ( arr) = value {
122+ for item in arr {
123+ let formatted = format_sshd_value ( key, item) ?;
124+ writeln ! ( & mut config_text, "{key} {formatted}" ) ?;
125+ }
126+ } else {
127+ // Single value for repeatable keyword, write as-is
128+ let formatted = format_sshd_value ( key, value) ?;
129+ writeln ! ( & mut config_text, "{key} {formatted}" ) ?;
130+ }
119131 } else {
120- return Err ( SshdConfigError :: InvalidInput ( t ! ( "set.valueMustBeString" , key = key) . to_string ( ) ) ) ;
132+ // Handle non-repeatable keywords - format and write single line
133+ let formatted = format_sshd_value ( key, value) ?;
134+ writeln ! ( & mut config_text, "{key} {formatted}" ) ?;
121135 }
122136 }
123137 } else {
0 commit comments