Skip to content

Commit 4165c41

Browse files
make permit_root_login an enumeration
1 parent fa39013 commit 4165c41

File tree

5 files changed

+61
-4
lines changed

5 files changed

+61
-4
lines changed

src/sonic-yang-models/doc/Configuration.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2952,7 +2952,11 @@ In this table, we allow configuring ssh server global settings. This will featur
29522952
- ports - Ssh port numbers - string of port numbers seperated by ','
29532953
- inactivity_timeout - Inactivity timeout for SSH session, allowed values: 0-35000 (min), default value: 15 (min)
29542954
- max_sessions - Max number of concurrent logins, allowed values: 0-100 (where 0 means no limit), default value: 0
2955-
- permit_root_login - Whether or not to allow root login. Boolean.
2955+
- permit_root_login - Whether or not to allow root login. Default value: "prohibit-password"
2956+
- "yes"
2957+
- "prohibit-password"
2958+
- "forced-commands-only"
2959+
- "no"
29562960
- password_authentication - Whether or not to allow password authentication. Boolean.
29572961
- ciphers - Ciphers to allow. See `ssh -Q ciphers`
29582962
- kex_algorithms - Key Exchange algorithms to allow. See `ssh -Q kex_algorithms`

src/sonic-yang-models/tests/files/sample_config_db.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2588,7 +2588,7 @@
25882588
"ports": "22",
25892589
"inactivity_timeout": "15",
25902590
"max_sessions": "0",
2591-
"permit_root_login": "false",
2591+
"permit_root_login": "no",
25922592
"password_authentication": "true",
25932593
25942594
"kex_algorithms": [ "sntrup761x25519-sha512", "curve25519-sha256", "ecdh-sha2-nistp521" ],

src/sonic-yang-models/tests/yang_model_tests/tests/ssh-server.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
"SSH_SERVER_VALID_MODIFIED": {
66
"desc": "Configure modified SSH_SERVER."
77
},
8+
"SSH_SERVER_PERMIT_ROOT_YES": {
9+
"desc": "permit_root_login: yes"
10+
},
11+
"SSH_SERVER_PERMIT_ROOT_NO": {
12+
"desc": "permit_root_login: no"
13+
},
14+
"SSH_SERVER_PERMIT_ROOT_PROHIBIT_PASSWORD": {
15+
"desc": "permit_root_login: prohibit-password"
16+
},
17+
"SSH_SERVER_PERMIT_ROOT_FORCED_COMMANDS_ONLY": {
18+
"desc": "permit_root_login: forced-commands-only"
19+
},
820
"SSH_SERVER_INVALID_AUTH_RETRIES": {
921
"desc": "Configure invalid number of authentication retries in SSH_SERVER.",
1022
"eStrKey" : "Pattern",

src/sonic-yang-models/tests/yang_model_tests/tests_config/ssh-server.json

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"ports": "22",
99
"inactivity_timeout": "15",
1010
"max_sessions": "0",
11-
"permit_root_login": "false",
11+
"permit_root_login": "no",
1212
"password_authentication": "true",
1313
1414
"kex_algorithms": [ "sntrup761x25519-sha512", "curve25519-sha256", "ecdh-sha2-nistp521" ],
@@ -28,6 +28,42 @@
2828
}
2929
}
3030
},
31+
"SSH_SERVER_PERMIT_ROOT_YES": {
32+
"sonic-ssh-server:sonic-ssh-server": {
33+
"sonic-ssh-server:SSH_SERVER": {
34+
"POLICIES":{
35+
"permit_root_login": "yes"
36+
}
37+
}
38+
}
39+
},
40+
"SSH_SERVER_PERMIT_ROOT_NO": {
41+
"sonic-ssh-server:sonic-ssh-server": {
42+
"sonic-ssh-server:SSH_SERVER": {
43+
"POLICIES":{
44+
"permit_root_login": "no"
45+
}
46+
}
47+
}
48+
},
49+
"SSH_SERVER_PERMIT_ROOT_PROHIBIT_PASSWORD": {
50+
"sonic-ssh-server:sonic-ssh-server": {
51+
"sonic-ssh-server:SSH_SERVER": {
52+
"POLICIES":{
53+
"permit_root_login": "prohibit-password"
54+
}
55+
}
56+
}
57+
},
58+
"SSH_SERVER_PERMIT_ROOT_FORCED_COMMANDS_ONLY": {
59+
"sonic-ssh-server:sonic-ssh-server": {
60+
"sonic-ssh-server:SSH_SERVER": {
61+
"POLICIES":{
62+
"permit_root_login": "forced-commands-only"
63+
}
64+
}
65+
}
66+
},
3167
"SSH_SERVER_INVALID_AUTH_RETRIES": {
3268
"sonic-ssh-server:sonic-ssh-server": {
3369
"sonic-ssh-server:SSH_SERVER": {

src/sonic-yang-models/yang-models/sonic-ssh-server.yang

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ module sonic-ssh-server {
6161
}
6262
leaf permit_root_login {
6363
description "Specifies whether root can log in using ssh.";
64-
type boolean;
64+
type enumeration {
65+
enum "yes";
66+
enum "prohibit-password";
67+
enum "forced-commands-only";
68+
enum "no";
69+
}
6570
}
6671
leaf password_authentication {
6772
description "Specifies whether password authentication is enabled.";

0 commit comments

Comments
 (0)