Configure Client/ServerAlive* options
Change-Id: I46802467b4fb790bf7ed6536575e47253e02bf04
diff --git a/README.rst b/README.rst
index b22cc25..b82a36b 100644
--- a/README.rst
+++ b/README.rst
@@ -41,6 +41,16 @@
type: rsa
fingerprint: dd:fa:e8:68:b1:ea:ea:a0:63:f1:5a:55:48:e1:7e:37
+Configure keep alive settings:
+
+.. code-block:: yaml
+
+ openssh:
+ client:
+ alive:
+ interval: 600
+ count: 3
+
OpenSSH server
--------------
@@ -114,6 +124,19 @@
command: /usr/bin/sss_ssh_authorizedkeys
user: nobody
+Configure keep alive settings:
+
+.. code-block:: yaml
+
+ openssh:
+ server:
+ alive:
+ keep: yes
+ interval: 600
+ count: 3
+ #
+ # will give you an timeout of 30 minutes (600 sec x 3)
+
Read more
=========
diff --git a/openssh/files/ssh_config b/openssh/files/ssh_config
index 63974d7..84c4482 100644
--- a/openssh/files/ssh_config
+++ b/openssh/files/ssh_config
@@ -20,3 +20,10 @@
ProxyCommand connect -H {{ network.proxy.host }}:{{ network.proxy.port }} %h %p
{%- endif %}
{% if client.stricthostkeychecking is not defined %}{% else %}StrictHostKeyChecking no{% endif %}
+ {%- if client.get('alive', {'interval': None}).interval is number %}
+ ServerAliveInterval {{ client.alive.interval }}
+ {% endif %}
+ {%- if client.get('alive', {'count': None}).count is number %}
+ ServerAliveCountMax {{ client.alive.count }}
+ {% endif %}
+
diff --git a/openssh/files/sshd_config b/openssh/files/sshd_config
index 8ecc5a9..783412a 100755
--- a/openssh/files/sshd_config
+++ b/openssh/files/sshd_config
@@ -111,9 +111,16 @@
X11DisplayOffset {{ server.get('x11', {}).get('display_offset', '10') }}
PrintMotd {% if server.get('print_motd', False) %}yes{% else %}no{% endif %}
PrintLastLog {% if server.get('print_lastlog', True) %}yes{% else %}no{% endif %}
-TCPKeepAlive yes
+TCPKeepAlive {{ server.get('alive', {}).get('keep','yes') }}
#UseLogin no
+{%- if server.get('alive', {'interval': None}).interval is number %}
+ClientAliveInterval {{ server.alive.interval }}
+{% endif %}
+{%- if server.get('alive', {'count': None}).count is number %}
+ClientAliveCountMax {{ server.alive.count }}
+{% endif %}
+
{%- if server.max_sessions is defined %}
MaxSessions {{ server.max_sessions }}
{%- else %}
diff --git a/tests/pillar/openssh_client.sls b/tests/pillar/openssh_client.sls
index da4099b..7915aae 100644
--- a/tests/pillar/openssh_client.sls
+++ b/tests/pillar/openssh_client.sls
@@ -16,4 +16,7 @@
- name: repo.domain.com
type: rsa
fingerprint: dd:fa:e8:68:b1:ea:ea:a0:63:f1:5a:55:48:e1:7e:37
+ alive:
+ interval: 600
+ count: 3
diff --git a/tests/pillar/openssh_server.sls b/tests/pillar/openssh_server.sls
index d5e18ac..140f6fc 100644
--- a/tests/pillar/openssh_server.sls
+++ b/tests/pillar/openssh_server.sls
@@ -17,3 +17,7 @@
bind:
address: 0.0.0.0
port: 8000
+ alive:
+ keep: no
+ interval: 600
+ # count: 3