Skip to content

Commit

Permalink
supports legacy hmac and kex
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Sep 14, 2023
1 parent f6fbdd8 commit ec70c3e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
6 changes: 2 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ members = [
"ares-push",
"ares-launch",
"ares-device",
]
]

[patch.crates-io]
libssh-rs = { git = "https://github.com/mariotaku/libssh-rs.git", branch = "feature/more-auth-options" }
libssh-rs-sys = { git = "https://github.com/mariotaku/libssh-rs.git", branch = "feature/more-auth-options" }
2 changes: 1 addition & 1 deletion ares-device/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ gtk = "0.17.1"
embed-manifest = "1.3.1"

[package.metadata.deb]
section = "devel"
section = "devel"
38 changes: 36 additions & 2 deletions common/connection/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,47 @@ pub enum SessionError {

impl NewSession for Device {
fn new_session(&self) -> Result<Session, SessionError> {
let kex = vec![
"curve25519-sha256",
"[email protected]",
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
"diffie-hellman-group18-sha512",
"diffie-hellman-group16-sha512",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group14-sha256",
"diffie-hellman-group1-sha1",
"diffie-hellman-group14-sha1",
];
let hmac = vec![
"[email protected]",
"[email protected]",
"hmac-sha2-256",
"hmac-sha2-512",
"hmac-sha1-96",
"hmac-sha1",
"hmac-md5",
];
let key_types = vec![
"ssh-ed25519",
"ecdsa-sha2-nistp521",
"ecdsa-sha2-nistp384",
"ecdsa-sha2-nistp256",
"rsa-sha2-512",
"rsa-sha2-256",
"ssh-rsa",
];
let session = Session::new()?;
session.set_option(SshOption::Timeout(Duration::from_secs(10)))?;
session.set_option(SshOption::Hostname(self.host.clone()))?;
session.set_option(SshOption::Port(self.port.clone()))?;
session.set_option(SshOption::User(Some(self.username.clone())))?;
session.set_option(SshOption::HostKeys(format!("ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa")))?;
session.set_option(SshOption::PublicKeyAcceptedTypes(format!("ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa")))?;
session.set_option(SshOption::KeyExchange(kex.join(",")))?;
session.set_option(SshOption::HmacCS(hmac.join(",")))?;
session.set_option(SshOption::HmacSC(hmac.join(",")))?;
session.set_option(SshOption::HostKeys(key_types.join(",")))?;
session.set_option(SshOption::PublicKeyAcceptedTypes(key_types.join(",")))?;
session.set_option(SshOption::ProcessConfig(false))?;
#[cfg(windows)]
{
Expand Down

0 comments on commit ec70c3e

Please sign in to comment.