Add native Dosh host trust foundation
This commit is contained in:
@@ -20,6 +20,20 @@ pub struct ServerConfig {
|
||||
pub shell: String,
|
||||
pub sessions_dir: String,
|
||||
pub secret_path: String,
|
||||
#[serde(default = "default_true")]
|
||||
pub native_auth: bool,
|
||||
#[serde(default = "default_host_key")]
|
||||
pub host_key: String,
|
||||
#[serde(default = "default_authorized_keys")]
|
||||
pub authorized_keys: Vec<String>,
|
||||
#[serde(default = "default_native_auth_rate_limit_per_minute")]
|
||||
pub native_auth_rate_limit_per_minute: u32,
|
||||
#[serde(default = "default_true")]
|
||||
pub allow_tcp_forwarding: bool,
|
||||
#[serde(default)]
|
||||
pub allow_remote_forwarding: bool,
|
||||
#[serde(default)]
|
||||
pub allow_agent_forwarding: bool,
|
||||
}
|
||||
|
||||
impl Default for ServerConfig {
|
||||
@@ -39,6 +53,13 @@ impl Default for ServerConfig {
|
||||
shell: std::env::var("SHELL").unwrap_or_else(|_| "/bin/sh".to_string()),
|
||||
sessions_dir: "~/.local/share/dosh/sessions".to_string(),
|
||||
secret_path: "~/.config/dosh/secret".to_string(),
|
||||
native_auth: true,
|
||||
host_key: default_host_key(),
|
||||
authorized_keys: default_authorized_keys(),
|
||||
native_auth_rate_limit_per_minute: default_native_auth_rate_limit_per_minute(),
|
||||
allow_tcp_forwarding: true,
|
||||
allow_remote_forwarding: false,
|
||||
allow_agent_forwarding: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,6 +80,20 @@ pub struct ClientConfig {
|
||||
pub predict: bool,
|
||||
pub cache_attach_tickets: bool,
|
||||
pub credential_cache: String,
|
||||
#[serde(default = "default_auth_preference")]
|
||||
pub auth_preference: String,
|
||||
#[serde(default)]
|
||||
pub trust_on_first_use: bool,
|
||||
#[serde(default = "default_native_auth_timeout_ms")]
|
||||
pub native_auth_timeout_ms: u64,
|
||||
#[serde(default = "default_known_hosts")]
|
||||
pub known_hosts: String,
|
||||
#[serde(default = "default_identity_files")]
|
||||
pub identity_files: Vec<String>,
|
||||
#[serde(default = "default_true")]
|
||||
pub use_ssh_agent: bool,
|
||||
#[serde(default)]
|
||||
pub forward_agent: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
@@ -93,10 +128,52 @@ impl Default for ClientConfig {
|
||||
predict: false,
|
||||
cache_attach_tickets: true,
|
||||
credential_cache: "~/.local/share/dosh/credentials".to_string(),
|
||||
auth_preference: default_auth_preference(),
|
||||
trust_on_first_use: false,
|
||||
native_auth_timeout_ms: default_native_auth_timeout_ms(),
|
||||
known_hosts: default_known_hosts(),
|
||||
identity_files: default_identity_files(),
|
||||
use_ssh_agent: true,
|
||||
forward_agent: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_host_key() -> String {
|
||||
"~/.config/dosh/host_key".to_string()
|
||||
}
|
||||
|
||||
fn default_authorized_keys() -> Vec<String> {
|
||||
vec![
|
||||
"~/.ssh/authorized_keys".to_string(),
|
||||
"~/.config/dosh/authorized_keys".to_string(),
|
||||
]
|
||||
}
|
||||
|
||||
fn default_native_auth_rate_limit_per_minute() -> u32 {
|
||||
30
|
||||
}
|
||||
|
||||
fn default_auth_preference() -> String {
|
||||
"native,ssh".to_string()
|
||||
}
|
||||
|
||||
fn default_native_auth_timeout_ms() -> u64 {
|
||||
700
|
||||
}
|
||||
|
||||
fn default_known_hosts() -> String {
|
||||
"~/.config/dosh/known_hosts".to_string()
|
||||
}
|
||||
|
||||
fn default_identity_files() -> Vec<String> {
|
||||
vec!["~/.ssh/id_ed25519".to_string()]
|
||||
}
|
||||
|
||||
pub fn load_server_config(path: Option<PathBuf>) -> Result<ServerConfig> {
|
||||
let path = path.unwrap_or_else(|| expand_tilde("~/.config/dosh/server.toml"));
|
||||
if !path.exists() {
|
||||
|
||||
Reference in New Issue
Block a user