Skip to content

Commit

Permalink
Allow retrieving peer SSH Protocol Version String
Browse files Browse the repository at this point in the history
  • Loading branch information
amtelekom committed Mar 7, 2024
1 parent f1985e1 commit ddef32c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions russh/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ where
strict_kex: false,
alive_timeouts: 0,
received_data: false,
remote_sshid: String::from_utf8_lossy(sshid).into(),
},
session_receiver,
session_sender,
Expand Down
5 changes: 5 additions & 0 deletions russh/src/client/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,9 @@ impl Session {
0
}
}

/// Returns the SSH ID (Protocol Version + Software Version) the server sent when connecting
pub fn remote_sshid(&self) -> &str {
&self.common.remote_sshid
}
}
1 change: 1 addition & 0 deletions russh/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ async fn read_ssh_id<R: AsyncRead + Unpin>(
strict_kex: false,
alive_timeouts: 0,
received_data: false,
remote_sshid: String::from_utf8_lossy(sshid).into(),
})
}

Expand Down
5 changes: 5 additions & 0 deletions russh/src/server/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,11 @@ impl Session {
}
}

/// Returns the SSH ID (Protocol Version + Software Version) the client sent when connecting
pub fn remote_sshid(&self) -> &str {
&self.common.remote_sshid
}

pub(crate) fn maybe_send_ext_info(&mut self) {
if let Some(ref mut enc) = self.common.encrypted {
// If client sent a ext-info-c message in the kex list, it supports RFC 8308 extension negotiation.
Expand Down
1 change: 1 addition & 0 deletions russh/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub(crate) struct Encrypted {

pub(crate) struct CommonSession<Config> {
pub auth_user: String,
pub remote_sshid: String,
pub config: Config,
pub encrypted: Option<Encrypted>,
pub auth_method: Option<auth::Method>,
Expand Down

0 comments on commit ddef32c

Please sign in to comment.