cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3289
Views
10
Helpful
2
Replies

How does ssh-keep-alive work in NSO?

Hi, I am trying to use ssh-keep-alive to keep a connection open to cisco devices that have an exec-timeout set on their vty line. 

I have set the interval to 60 (seconds), count to 5, and session-pool-idle-time to 240 (4 minutes). The session-pool-idle time will keep the connection open for 4 minutes while idle if there is not a exec-timeout on the vty line. I thought setting the ssh-keep-alive settings would something like a keep alive packet to the device so as to not be idle, however it still times out at the exec-timeout or if there is not exec-timeout, the session-pool idle-time.

 

admin@Mothership-6(config)# show full-configuration devices global-settings
devices global-settings ssh-keep-alive interval 60
devices global-settings ssh-keep-alive count 5
devices global-settings session-pool idle-time 240

1 Accepted Solution

Accepted Solutions

I found out that exec-timeout deals specifically with sending exec (configure mode) commands to the device, so an idle session or ssh-keep-alive would not work because it is not an exec command.

View solution in original post

2 Replies 2

joepak
Cisco Employee
Cisco Employee

Hi,

 

It seems you have a couple of questions. Take a look at the following yang descriptions for the parameters you are asking and let me know if it clears anything or if you still have questions. If so, we can expand more on what you are expecting. I'm not sure if you have already digged into the descriptions for the following, but if you didn't, it may be useful to read and see how it's perceived from the NSO side.

 

Take a look below and let me know if there still needs to be an elaboration.

 

grouping device-profile-parameters {
      description
        "A set of parameters to use when communicating with a device.

         These parameters can be set on:

           o  global-settings
           o  device-profile
           o  device

         If a parameter is set on the device, its value is used.
         Otherwise, if the paramater is set in the device's
         device-profile, its value is used.  Otherwise, the global
         setting is used, if set.  Otherwise, the value used depends on
         the NED type.";

      uses timeouts;

      container ssh-keep-alive {
        description
          "Controls SSH keep alive settings when communicating from this
           node to devices.";
        tailf:info "Controls SSH keep alive settings";
        leaf interval {
          type uint32 {
            range "0..4294967";
          }
          units "seconds";
          description
            "Seconds between SSH keep alive activity.";
        }
        leaf count {
          type uint8;
          description
            "Number of intervals to fail before failing the connection.";
        }
      }

      container ned-keep-alive {
        description
          "Controls NED keep alive settings when communicating from this
           node to devices. The keep alive settings can be configured for
           NSO to periodically perform activity to keep the session open.
           This is useful when for example CLI sessions have low idle timeouts.
           These settings only take effect if the NED actually implements
           this callback.";
        tailf:info "Controls NED keep alive settings";
        leaf interval {
          type uint32 {
            range "0..4294967";
          }

          units "seconds";
          description
            "Seconds between NED keep alive activity.";
        }
        leaf count {
          type uint8;
          description
            "Number of intervals to fail before failing the connection.";
        }
      }
-------

 

For session-pool:

 

      container session-pool {
        tailf:info "Control how sessions to related devices can be pooled.";
        description
          "NCS uses NED sessions when performing transactions, actions
           etc towards a device. When such a task is completed the NED
           session can either be closed or pooled.

           Pooling a NED session means that the session to the
           device is kept open for a configurable amount of
           time. During this time the session can be re-used for a new
           task. Thus the pooling concept exists to reduce the number
           of new connections needed towards a device that is often
           used.

           By default NCS uses pooling for all device types except
           snmp. Normally there is no need to change the default
           values.";

        leaf max-sessions {
          type union {
            type enumeration {
              enum unlimited;
            }
            type uint32;
          }
          description
            "Controls the maximum number of open sessions in the pool for
             a specific device. When this threshold is exceeded the oldest
             session in the pool will be closed.
             A Zero value will imply that pooling is disabled for
             this specific device. The label 'unlimited' implies that no
             upper limit exists for this specific device";
        }

        leaf idle-time {
          tailf:info
            "The maximum time that a session is kept open in the pool";
          type uint32 {
            range "1..4294967";
          }
          units "seconds";
          description
            "The maximum time that a session is kept open in the pool.
             If the session is not requested and used before the
             idle-time has expired, the session is closed.
             If no idle-time is set the default is 30 seconds.";
        }
      }

I found out that exec-timeout deals specifically with sending exec (configure mode) commands to the device, so an idle session or ssh-keep-alive would not work because it is not an exec command.

Polls
🚀 Help Shape the Developer Track!

📌 We’re excited to dive deep into Network Automation with NSO & CWM at Automation Developer Days 2025.

📊 Let us know which topic you’re most interested in!