- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.7k
 
SSH hardening configuration options #22308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            lguohan
  merged 2 commits into
  sonic-net:master
from
bhouse-nexthop:bhouse-nexthop/ssh-config
  
      
      
   
  Oct 25, 2025 
      
    
      
        
          +211
        
        
          −3
        
        
          
        
      
    
  
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            2 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or 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 | 
|---|---|---|
| 
          
            
          
           | 
    @@ -3055,6 +3055,15 @@ In this table, we allow configuring ssh server global settings. This will featur | |
| - ports - Ssh port numbers - string of port numbers seperated by ',' | ||
| - inactivity_timeout - Inactivity timeout for SSH session, allowed values: 0-35000 (min), default value: 15 (min) | ||
| - max_sessions - Max number of concurrent logins, allowed values: 0-100 (where 0 means no limit), default value: 0 | ||
| - permit_root_login - Whether or not to allow root login. Default value: "prohibit-password" | ||
| - "yes" | ||
| - "prohibit-password" | ||
| - "forced-commands-only" | ||
| - "no" | ||
| - password_authentication - Whether or not to allow password authentication. Boolean. | ||
| - ciphers - Ciphers to allow. See `ssh -Q ciphers` | ||
| - kex_algorithms - Key Exchange algorithms to allow. See `ssh -Q kex_algorithms` | ||
| - macs - MAC algorithms to allow. See `ssh -Q macs` | ||
| ``` | ||
| { | ||
| "SSH_SERVER": { | ||
| 
        
          
        
         | 
    @@ -3063,7 +3072,12 @@ In this table, we allow configuring ssh server global settings. This will featur | |
| "login_timeout": "120", | ||
| "ports": "22", | ||
| "inactivity_timeout": "15", | ||
| "max_sessions": "0" | ||
| "max_sessions": "0", | ||
| "permit_root_login": "false", | ||
| "password_authentication": "true", | ||
| "ciphers": [ "[email protected]", "[email protected]" ], | ||
| "kex_algorithms": [ "sntrup761x25519-sha512", "curve25519-sha256", "ecdh-sha2-nistp521" ], | ||
| "macs": [ "[email protected]", "hmac-sha2-512" ] | ||
| } | ||
| } | ||
| } | ||
| 
          
            
          
           | 
    ||
  
    
      This file contains hidden or 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 | 
|---|---|---|
| 
          
            
          
           | 
    @@ -2702,7 +2702,12 @@ | |
| "login_timeout": "120", | ||
| "ports": "22", | ||
| "inactivity_timeout": "15", | ||
| "max_sessions": "0" | ||
| "max_sessions": "0", | ||
| "permit_root_login": "no", | ||
| "password_authentication": "true", | ||
| "ciphers": [ "[email protected]", "[email protected]" ], | ||
| "kex_algorithms": [ "sntrup761x25519-sha512", "curve25519-sha256", "ecdh-sha2-nistp521" ], | ||
| "macs": [ "[email protected]", "hmac-sha2-512" ] | ||
| } | ||
| }, | ||
| 
     | 
||
| 
          
            
          
           | 
    ||
  
    
      This file contains hidden or 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 hidden or 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 | 
|---|---|---|
| 
          
            
          
           | 
    @@ -5,7 +5,14 @@ | |
| "POLICIES":{ | ||
| "authentication_retries": "6", | ||
| "login_timeout": "120", | ||
| "ports": "22" | ||
| "ports": "22", | ||
| "inactivity_timeout": "15", | ||
| "max_sessions": "0", | ||
| "permit_root_login": "no", | ||
| "password_authentication": "true", | ||
| "ciphers": [ "[email protected]", "[email protected]" ], | ||
| "kex_algorithms": [ "sntrup761x25519-sha512", "curve25519-sha256", "ecdh-sha2-nistp521" ], | ||
| "macs": [ "[email protected]", "hmac-sha2-512" ] | ||
| } | ||
| } | ||
| } | ||
| 
        
          
        
         | 
    @@ -21,6 +28,42 @@ | |
| } | ||
| } | ||
| }, | ||
| "SSH_SERVER_PERMIT_ROOT_YES": { | ||
| "sonic-ssh-server:sonic-ssh-server": { | ||
| "sonic-ssh-server:SSH_SERVER": { | ||
| "POLICIES":{ | ||
| "permit_root_login": "yes" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "SSH_SERVER_PERMIT_ROOT_NO": { | ||
| "sonic-ssh-server:sonic-ssh-server": { | ||
| "sonic-ssh-server:SSH_SERVER": { | ||
| "POLICIES":{ | ||
| "permit_root_login": "no" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "SSH_SERVER_PERMIT_ROOT_PROHIBIT_PASSWORD": { | ||
| "sonic-ssh-server:sonic-ssh-server": { | ||
| "sonic-ssh-server:SSH_SERVER": { | ||
| "POLICIES":{ | ||
| "permit_root_login": "prohibit-password" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "SSH_SERVER_PERMIT_ROOT_FORCED_COMMANDS_ONLY": { | ||
| "sonic-ssh-server:sonic-ssh-server": { | ||
| "sonic-ssh-server:SSH_SERVER": { | ||
| "POLICIES":{ | ||
| "permit_root_login": "forced-commands-only" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "SSH_SERVER_INVALID_AUTH_RETRIES": { | ||
| "sonic-ssh-server:sonic-ssh-server": { | ||
| "sonic-ssh-server:SSH_SERVER": { | ||
| 
          
            
          
           | 
    @@ -74,5 +117,50 @@ | |
| } | ||
| } | ||
| } | ||
| }, | ||
| "SSH_SERVER_INVALID_PERMIT_ROOT_LOGIN": { | ||
| "sonic-ssh-server:sonic-ssh-server": { | ||
| "sonic-ssh-server:SSH_SERVER": { | ||
| "POLICIES":{ | ||
| "permit_root_login": "invalid" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "SSH_SERVER_INVALID_PASSWORD_AUTHENTICATION": { | ||
| "sonic-ssh-server:sonic-ssh-server": { | ||
| "sonic-ssh-server:SSH_SERVER": { | ||
| "POLICIES":{ | ||
| "password_authentication": "invalid" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "SSH_SERVER_INVALID_CIPHERS": { | ||
| "sonic-ssh-server:sonic-ssh-server": { | ||
| "sonic-ssh-server:SSH_SERVER": { | ||
| "POLICIES":{ | ||
| "ciphers": [ "[email protected]", "invalid" ] | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "SSH_SERVER_INVALID_KEX_ALGORITHMS": { | ||
| "sonic-ssh-server:sonic-ssh-server": { | ||
| "sonic-ssh-server:SSH_SERVER": { | ||
| "POLICIES":{ | ||
| "kex_algorithms": [ "sntrup761x25519-sha512", "invalid" ] | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "SSH_SERVER_INVALID_MACS": { | ||
| "sonic-ssh-server:sonic-ssh-server": { | ||
| "sonic-ssh-server:SSH_SERVER": { | ||
| "POLICIES":{ | ||
| "macs": [ "[email protected]", "invalid" ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
  
    
      This file contains hidden or 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 | 
|---|---|---|
| 
          
            
          
           | 
    @@ -59,6 +59,75 @@ module sonic-ssh-server { | |
| range 0..100; | ||
| } | ||
| } | ||
| leaf permit_root_login { | ||
| description "Specifies whether root can log in using ssh."; | ||
| type enumeration { | ||
| enum "yes"; | ||
| enum "prohibit-password"; | ||
| enum "forced-commands-only"; | ||
| enum "no"; | ||
| } | ||
| } | ||
| leaf password_authentication { | ||
| description "Specifies whether password authentication is enabled."; | ||
| type boolean; | ||
| default true; | ||
| } | ||
| leaf-list ciphers { | ||
| description "Specifies the ciphers allowed."; | ||
| type enumeration { | ||
| enum "3des-cbc"; | ||
| enum "aes128-cbc"; | ||
| enum "aes192-cbc"; | ||
| enum "aes256-cbc"; | ||
| enum "aes128-ctr"; | ||
| enum "aes192-ctr"; | ||
| enum "aes256-ctr"; | ||
| enum "[email protected]"; | ||
| enum "[email protected]"; | ||
| enum "[email protected]"; | ||
| } | ||
| } | ||
| leaf-list kex_algorithms { | ||
| description "Specifies the available Key Exchange algorithms."; | ||
| type enumeration { | ||
| enum "diffie-hellman-group1-sha1"; | ||
| enum "diffie-hellman-group14-sha1"; | ||
| enum "diffie-hellman-group14-sha256"; | ||
| enum "diffie-hellman-group16-sha512"; | ||
| enum "diffie-hellman-group18-sha512"; | ||
| enum "diffie-hellman-group-exchange-sha1"; | ||
| enum "diffie-hellman-group-exchange-sha256"; | ||
| enum "ecdh-sha2-nistp256"; | ||
| enum "ecdh-sha2-nistp384"; | ||
| enum "ecdh-sha2-nistp521"; | ||
| enum "curve25519-sha256"; | ||
| enum "[email protected]"; | ||
| enum "sntrup761x25519-sha512"; | ||
| enum "[email protected]"; | ||
| } | ||
| } | ||
| leaf-list macs { | ||
| description "Specifies the available MAC (message authentication code) algorithms."; | ||
| type enumeration { | ||
| enum "hmac-sha1"; | ||
| enum "hmac-sha1-96"; | ||
| enum "hmac-sha2-256"; | ||
| enum "hmac-sha2-512"; | ||
| enum "hmac-md5"; | ||
| enum "hmac-md5-96"; | ||
| enum "[email protected]"; | ||
| enum "[email protected]"; | ||
| enum "[email protected]"; | ||
| enum "[email protected]"; | ||
| enum "[email protected]"; | ||
| enum "[email protected]"; | ||
| enum "[email protected]"; | ||
| enum "[email protected]"; | ||
| enum "[email protected]"; | ||
| enum "[email protected]"; | ||
| } | ||
| } | ||
| }/*container policies */ | ||
| } /* container SSH_SERVER */ | ||
| }/* container sonic-ssh-server */ | ||
| 
          
            
          
           | 
    ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.