Skip to content

Commit

Permalink
feat(ssh): make inactivity timeout configurable (#990)
Browse files Browse the repository at this point in the history
With this change, the SSH inactivity timeout is now configurable. By
default, is set at 5 minutes (300 seconds), which was the already
existing value.

Solves #943
  • Loading branch information
NefixEstrada committed May 31, 2024
1 parent 72236d0 commit 9582a6e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions warpgate-common/src/config/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ pub(crate) fn _default_ssh_listen() -> ListenEndpoint {
pub(crate) fn _default_ssh_keys_path() -> String {
"./data/keys".to_owned()
}

pub(crate) fn _default_ssh_inactivity_timeout() -> Duration {
Duration::SECOND * 60 * 5
}
4 changes: 4 additions & 0 deletions warpgate-common/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ pub struct SshConfig {

#[serde(default)]
pub host_key_verification: SshHostKeyVerificationMode,

#[serde(default = "_default_ssh_inactivity_timeout", with = "humantime_serde")]
pub inactivity_timeout: Duration,
}

impl Default for SshConfig {
Expand All @@ -128,6 +131,7 @@ impl Default for SshConfig {
keys: _default_ssh_keys_path(),
host_key_verification: Default::default(),
external_port: None,
inactivity_timeout: _default_ssh_inactivity_timeout(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion warpgate-protocol-ssh/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub async fn run_server(services: Services, address: SocketAddr) -> Result<()> {
russh::server::Config {
auth_rejection_time: Duration::from_secs(1),
auth_rejection_time_initial: Some(Duration::from_secs(0)),
inactivity_timeout: Some(Duration::from_secs(300)),
inactivity_timeout: Some(config.store.ssh.inactivity_timeout),
methods: MethodSet::PUBLICKEY | MethodSet::PASSWORD | MethodSet::KEYBOARD_INTERACTIVE,
keys: load_host_keys(&config)?,
event_buffer_size: 100,
Expand Down

0 comments on commit 9582a6e

Please sign in to comment.