-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ssh configurations to YANG model (#13338)
- Why I did it Implemented ssh configurations - How I did it Added ssh config table in configDB, once changed - hostcfgd will change the relevant OS files (sshd_config) - How to verify it Tests in sonic-host-services. Change relevant configs in configDB such as ports, and see sshd port was modified
- Loading branch information
1 parent
4303308
commit 7639df0
Showing
6 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/sonic-yang-models/tests/yang_model_tests/tests/ssh-server.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"SSH_SERVER_VALID": { | ||
"desc": "Configure default SSH_SERVER." | ||
}, | ||
"SSH_SERVER_VALID_MODIFIED": { | ||
"desc": "Configure modified SSH_SERVER." | ||
}, | ||
"SSH_SERVER_INVALID_AUTH_RETRIES": { | ||
"desc": "Configure invalid number of authentication retries in SSH_SERVER.", | ||
"eStrKey" : "Pattern", | ||
"eStr": ["1..100"] | ||
}, | ||
"SSH_SERVER_INVALID_LOGIN_TIMEOUT": { | ||
"desc": "Configure invalid login timeout value in SSH_SERVER.", | ||
"eStrKey" : "Pattern", | ||
"eStr": ["1..600"] | ||
}, | ||
"SSH_SERVER_INVALID_PORTS_1": { | ||
"desc": "Configure invalid port value in SSH_SERVER.", | ||
"eStr": "Invalid port numbers value" | ||
}, | ||
"SSH_SERVER_INVALID_PORTS_2": { | ||
"desc": "Configure invalid port value in SSH_SERVER.", | ||
"eStr": "Invalid port numbers value" | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/sonic-yang-models/tests/yang_model_tests/tests_config/ssh-server.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"SSH_SERVER_VALID": { | ||
"sonic-ssh-server:sonic-ssh-server": { | ||
"sonic-ssh-server:SSH_SERVER": { | ||
"POLICIES":{ | ||
"authentication_retries": "6", | ||
"login_timeout": "120", | ||
"ports": "22" | ||
} | ||
} | ||
} | ||
}, | ||
"SSH_SERVER_VALID_MODIFIED": { | ||
"sonic-ssh-server:sonic-ssh-server": { | ||
"sonic-ssh-server:SSH_SERVER": { | ||
"POLICIES":{ | ||
"authentication_retries": "16", | ||
"login_timeout": "140", | ||
"ports": "22,222" | ||
} | ||
} | ||
} | ||
}, | ||
"SSH_SERVER_INVALID_AUTH_RETRIES": { | ||
"sonic-ssh-server:sonic-ssh-server": { | ||
"sonic-ssh-server:SSH_SERVER": { | ||
"POLICIES":{ | ||
"authentication_retries": "200" | ||
} | ||
} | ||
} | ||
}, | ||
"SSH_SERVER_INVALID_LOGIN_TIMEOUT": { | ||
"sonic-ssh-server:sonic-ssh-server": { | ||
"sonic-ssh-server:SSH_SERVER": { | ||
"POLICIES":{ | ||
"login_timeout": "606" | ||
} | ||
} | ||
} | ||
}, | ||
"SSH_SERVER_INVALID_PORTS_1": { | ||
"sonic-ssh-server:sonic-ssh-server": { | ||
"sonic-ssh-server:SSH_SERVER": { | ||
"POLICIES":{ | ||
"ports": "port22" | ||
} | ||
} | ||
} | ||
}, | ||
"SSH_SERVER_INVALID_PORTS_2": { | ||
"sonic-ssh-server:sonic-ssh-server": { | ||
"sonic-ssh-server:SSH_SERVER": { | ||
"POLICIES":{ | ||
"ports": "22.222" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
//filename: sonic-ssh-server.yang | ||
module sonic-ssh-server { | ||
yang-version 1.1; | ||
namespace "https://github.com/sonic-net/sonic-ssh-server"; | ||
prefix sshg; | ||
|
||
description "SSH SERVER CONFIG YANG Module for SONiC OS"; | ||
|
||
revision 2022-08-29 { | ||
description | ||
"First Revision"; | ||
} | ||
|
||
container sonic-ssh-server { | ||
container SSH_SERVER { | ||
description "SSH SERVER CONFIG part of config_db.json"; | ||
container POLICIES { | ||
leaf authentication_retries { | ||
description "number of login attepmts"; | ||
default 6; | ||
type uint32 { | ||
range 1..100; | ||
} | ||
} | ||
leaf login_timeout { | ||
description "login timeout (secs unit)"; | ||
default 120; | ||
type uint32 { | ||
range 1..600; | ||
} | ||
} | ||
leaf ports { | ||
description "ssh port numbers"; | ||
default "22"; | ||
type string { | ||
pattern '([1-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-6])(,([1-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-6]))*' { | ||
error-message "Invalid port numbers value"; | ||
error-app-tag ssh-server-ports-invalid-value; | ||
} | ||
} | ||
} | ||
}/*container policies */ | ||
} /* container SSH_SERVER */ | ||
}/* container sonic-ssh-server */ | ||
}/* end of module sonic-ssh-server */ |