Skip to main content

bssh/ssh/client/
config.rs

1// Copyright 2025 Lablup Inc. and Jeongkyu Shin
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use crate::security::Password;
16use crate::ssh::SessionPolicy;
17use crate::ssh::known_hosts::StrictHostKeyChecking;
18use crate::ssh::tokio_client::{SshConnectionConfig, SshConnectionConfigResolver};
19use std::path::Path;
20use std::sync::Arc;
21
22/// Configuration for SSH connection and command execution
23#[derive(Clone)]
24pub struct ConnectionConfig<'a> {
25    pub key_path: Option<&'a Path>,
26    pub strict_mode: Option<StrictHostKeyChecking>,
27    pub use_agent: bool,
28    pub use_password: bool,
29    #[cfg(target_os = "macos")]
30    pub use_keychain: bool,
31    pub timeout_seconds: Option<u64>,
32    pub connect_timeout_seconds: Option<u64>,
33    pub jump_hosts_spec: Option<&'a str>,
34    /// SSH keepalive / inactivity settings. `None` falls back to defaults.
35    pub ssh_connection_config: Option<&'a SshConnectionConfig>,
36    /// Per-host connection settings resolver used by jump chains.
37    pub ssh_connection_config_resolver: Option<&'a SshConnectionConfigResolver>,
38    /// Resolved environment, command, TTY, and channel request policy.
39    pub session_policy: Option<&'a SessionPolicy>,
40    /// Pre-collected SSH password shared with every per-node auth task.
41    ///
42    /// When `use_password` is `true`, this MUST be `Some(_)`; the dispatcher
43    /// is responsible for prompting once up-front and threading the value
44    /// through. `None` means "no pre-collected password" — `auth.rs` then
45    /// falls back to its in-task prompt (used for the OpenSSH-style
46    /// password-fallback path only).
47    pub ssh_password: Option<Arc<Password>>,
48}