- SSH server global config HLD
- 1. Table of Content
- 1.1. Revision
- 1.2. Scope
- 1.3. Definitions/Abbreviations
- 1.4. Overview
- 1.5. Requirements
- 1.6. Architecture Design
- 1.7. High-Level Design - Flow diagram
- 1.8. Init flow
- 1.9. SAI api
- 1.10. Configuration and management
- 1.11. Warmboot and Fastboot Design Impact
- 1.12. Restrictions/Limitations
- 1.13. Testing Requirements/Design
- 1.14. Open/Action items - if any
- 1. Table of Content
This hld doc for ssh server global configurations describes the requirements, architecture and general flow details of ssh server config in SONIC OS based switches.
SSH - secure shell
TCP - Transmission Control protocol
We want to allow configuring ssh server global settings. This will feature will include 3 configurations in the first phase, but can be extended easily to include additional configurations.
This feature requires a dedicated table in the configuration DB, and enhancements of hostcfg demon, in order to allow modifing the relvant ssh configuration files. In order to override ssh configurations, we need to have write access to ssh config files such as /etc/ssh/sshd_config
We want to enhance configDB to include table for ssh server global configurations. In addition, hostcfg demon will include a dedicated flow in order to modify ssh config files, once ssh server global config table entries are changed.
We want to enable global ssh server configuration in SONIC. In order to do so will touch few areas in the system:
- configDB - to include a dedicated table for configurations
- hostcfg demon - to update ssh config files once configDB relevant areas are modified (and for this feature, ssh server config table)
- OS ssh config files - specific for this stage we are only /etc/ssh/sshd_config is going to be modifed by the hostcfg demon.
- OS ssh service - to be restarted after each configuration change.
Note:
The Daemon is running in the host (without container) that matches this feature, because it is basically writing policies on ssh config files from the OS.
When the feature is enabled, by modifying the DB manually, user will set ssh server policies/configuration (see options below) by modifing CONFIG_DB in SSH_SERVER_TABLE.
The hostcfgd daemon will be extended to listen to ssh policies/configurations from SSH_SERVER table, parse the inputs and set the new policies to ssh config files, and update ssh server afterwards.
We want to enable configuring the following policies, with default values are taken from OS (Debian):
Policy | Action | Param values | Default OS value |
---|---|---|---|
authentication retries | Number of attempts to try to log in before rejecting the session | 3-100 | 6 |
login timeout | SSH session timeout | 1-600 (secs) | 120 |
ports | Port numbers for SSH | 1-65535 | 22 |
During init flow we will set default ssh policies, same as default values in DebianOS. Default values will be added to init_cfg.json.j2, and updated in sshd_config file accordingly.
Description of default values in init_cfg.json regarding ssh server config:
authentication retries: 6
login timeout: 120 //seconds
ports: 22
NA
SSH_SERVER:{
POLICIES:{
"authentication_retries": {{num}}
"login_timeout": {{secs}}
"ports": {{num}}
}
}
; Defines schema for SSH_SERVER configuration attributes in SSH_SERVER table:
key = "POLICIES" ;ssh server configuration
; field = value
authentication_retries = 3*DIGIT ; number of login attepmts, should be 100 max
LOGIN_TIMEOUT = 3*DIGIT ; login timeout in secs unit, max is 600 secs
PORTS = 5*DIGIT ; ssh port number - max is 65535
//filename: sonic-ssh_server.yang
module sonic-ssh-server {
yang-version 1.1;
namespace "http://github.com/Azure/sonic-ssh_server";
prefix ssh-server;
description "ssh server CONFIG YANG Module for SONiC OS";
revision 2023-01-26 {
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 uint8 {
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 */
The ConfigDB will be extended with next objects:
{
"SSH_SERVER": {
"POLICIES":{
"authentication_retries": "6",
"login_timeout": "120",
"ports": "22",
}
}
}
NA
NA
Explain what kind of unit testing, system testing, regression testing, warmboot/fastboot testing, etc., Ensure that the existing warmboot/fastboot requirements are met. For example, if the current warmboot feature expects maximum of 1 second or zero second data disruption, the same should be met even after the new feature/enhancement is implemented. Explain the same here. Example sub-sections for unit test cases and system test cases are given below.
- Configuration – good flow
- Verify default values
- Configure all types and check updated values
- Configure authentication_retries to X and try to connect with wrong password X+1 times
- Configure login_timeout to X, try to connect and wait for X+5 seconds (need to disconnect)
- Configure ports to 222 and see if unable to connect to 22
NOTE: All the sections and sub-sections given above are mandatory in the design document. Users can add additional sections/sub-sections if required.