Skip to content

Commit ebc8775

Browse files
committed
feat: add jump host ssh
feat: add jump host ssh
2 parents d6000d4 + 948b666 commit ebc8775

5 files changed

Lines changed: 374 additions & 156 deletions

File tree

warpgate-admin/src/api/ssh_connection_test.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ pub struct Api;
1818
struct CheckSshHostKeyRequest {
1919
host: String,
2020
port: u16,
21+
username: Option<String>,
22+
allow_insecure_algos: Option<bool>,
23+
auth: Option<SSHTargetAuth>,
24+
jump_host: Option<warpgate_common::SSHJumpHostOptions>,
2125
}
2226

2327
#[derive(Object)]
@@ -55,11 +59,14 @@ impl Api {
5559
RCCommand::Connect(TargetSSHOptions {
5660
host: body.host.clone(),
5761
port: body.port,
58-
username: String::new(),
59-
allow_insecure_algos: None,
60-
auth: SSHTargetAuth::Password(SshTargetPasswordAuth {
61-
password: String::new().into(),
62+
username: body.username.clone().unwrap_or_default(),
63+
allow_insecure_algos: body.allow_insecure_algos,
64+
auth: body.auth.clone().unwrap_or_else(|| {
65+
SSHTargetAuth::Password(SshTargetPasswordAuth {
66+
password: String::new().into(),
67+
})
6268
}),
69+
jump_host: body.jump_host.clone(),
6370
}),
6471
None,
6572
));
@@ -68,6 +75,10 @@ impl Api {
6875
let key = loop {
6976
match handles.event_rx.recv().await {
7077
Some(RCEvent::HostKeyReceived(key)) => break key,
78+
Some(RCEvent::HostKeyUnknown(key, reply)) => {
79+
let _ = reply.send(true);
80+
break key;
81+
},
7182
Some(RCEvent::ConnectionError(err)) => return Err(anyhow::Error::from(err)),
7283
Some(RCEvent::Error(err)) => return Err(err),
7384
None => anyhow::bail!("Failed to connect to target"),

warpgate-common/src/config/target.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ impl Default for KubernetesTargetCertificateAuth {
2626
}
2727
}
2828

29+
#[derive(Debug, Deserialize, Serialize, Clone, Object, Default)]
30+
pub struct SSHJumpHostOptions {
31+
pub host: String,
32+
#[serde(default = "_default_ssh_port")]
33+
pub port: u16,
34+
#[serde(default = "_default_username")]
35+
pub username: String,
36+
#[serde(default)]
37+
pub auth: SSHTargetAuth,
38+
}
39+
2940
#[derive(Debug, Deserialize, Serialize, Clone, Object)]
3041
pub struct TargetSSHOptions {
3142
pub host: String,
@@ -37,6 +48,8 @@ pub struct TargetSSHOptions {
3748
pub allow_insecure_algos: Option<bool>,
3849
#[serde(default)]
3950
pub auth: SSHTargetAuth,
51+
#[serde(default)]
52+
pub jump_host: Option<SSHJumpHostOptions>,
4053
}
4154

4255
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, Union)]

0 commit comments

Comments
 (0)