Skip to content
Snippets Groups Projects
Unverified Commit 391749b7 authored by Jeff Evans's avatar Jeff Evans Committed by GitHub
Browse files

Make SSH heartbeat interval configurable (#14679)

Adding entry in public_settings.clj for ssh heartbeat interval, and referencing that from ssh.clj

Adding the heartbeat interval to the existing log message when tunnel is established

Adding mention of the env var to environment-variables.md
parent 49d24cb8
Branches
Tags
No related merge requests found
......@@ -1005,6 +1005,13 @@ Default: `X-Forwarded-For`
Identify the source of HTTP requests by this header's value, instead of its remote address. Related to [MB_DISABLE_SESSION_THROTTLE](#mb_disable_session_throttle).
#### `MB_SSH_HEARTBEAT_INTERVAL_SEC`
Type: integer<br>
Default: `180`
Controls how often the heartbeats are sent when an SSH tunnel is established (in seconds).
#### `MB_SSL_CERTIFICATE_PUBLIC_KEY`
Type: string<br>
......
......@@ -389,3 +389,9 @@
:visibility :public
:type :keyword
:default "sunday")
(defsetting ssh-heartbeat-interval-sec
(deferred-tru "Controls how often the heartbeats are sent when an SSH tunnel is established (in seconds).")
:visibility :public
:type :integer
:default 180)
(ns metabase.util.ssh
(:require [clojure.tools.logging :as log]
[metabase.public-settings :as public-settings]
[metabase.util :as u])
(:import java.io.ByteArrayInputStream
java.util.concurrent.TimeUnit
......@@ -51,18 +52,20 @@
tunnel-private-key-passphrase host port]}]
(let [^ConnectFuture conn-future (.connect client tunnel-user tunnel-host tunnel-port)
^SessionHolder conn-status (.verify conn-future default-ssh-timeout)
hb-sec (public-settings/ssh-heartbeat-interval-sec)
session (doto ^ClientSession (.getSession conn-status)
(maybe-add-tunnel-password! tunnel-pass)
(maybe-add-tunnel-private-key! tunnel-private-key tunnel-private-key-passphrase)
(.setSessionHeartbeat SessionHeartbeatController$HeartbeatType/IGNORE
TimeUnit/SECONDS
180)
hb-sec)
(.. auth (verify default-ssh-timeout)))
tracker (.createLocalPortForwardingTracker session
(SshdSocketAddress. "" 0)
(SshdSocketAddress. host port))
input-port (.. tracker getBoundAddress getPort)]
(log/trace (u/format-color 'cyan "creating ssh tunnel %s@%s:%s -L %s:%s:%s" tunnel-user tunnel-host tunnel-port input-port host port))
(log/trace (u/format-color 'cyan "creating ssh tunnel (heartbeating every %d seconds) %s@%s:%s -L %s:%s:%s"
hb-sec tunnel-user tunnel-host tunnel-port input-port host port))
[session tracker]))
(def ssh-tunnel-preferences
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment