Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ libc = "0.2"
ipnetwork = "0.21"
bcrypt = "0.19"
argon2 = "0.5"
rand = "0.8"
rand = "0.9"
ssh-key = { version = "0.6", features = ["std"] }
async-compression = { version = "0.4", features = ["tokio", "gzip"] }
serde_json = "1.0"
Expand Down
5 changes: 3 additions & 2 deletions src/bin/bssh_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,13 @@ fn check_config(cli: &Cli) -> Result<()> {
/// Generate SSH host keys
fn gen_host_key(key_type: &str, output: &PathBuf, _bits: u32) -> Result<()> {
use russh::keys::PrivateKey;
use ssh_key::rand_core::OsRng;
use ssh_key::LineEnding;

let key = match key_type.to_lowercase().as_str() {
"ed25519" => {
tracing::info!("Generating Ed25519 host key");
PrivateKey::random(&mut rand::thread_rng(), russh::keys::Algorithm::Ed25519)
PrivateKey::random(&mut OsRng, russh::keys::Algorithm::Ed25519)
.context("Failed to generate Ed25519 key")?
}
"rsa" => {
Expand All @@ -373,7 +374,7 @@ fn gen_host_key(key_type: &str, output: &PathBuf, _bits: u32) -> Result<()> {
}
tracing::info!(bits = _bits, "Generating RSA host key");
PrivateKey::random(
&mut rand::thread_rng(),
&mut OsRng,
russh::keys::Algorithm::Rsa {
hash: Some(russh::keys::HashAlg::Sha256),
},
Expand Down
3 changes: 2 additions & 1 deletion src/keygen/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use super::GeneratedKey;
use anyhow::{Context, Result};
use russh::keys::{Algorithm, HashAlg, PrivateKey};
use ssh_key::rand_core::OsRng;
use ssh_key::LineEnding;
use std::io::Write;
use std::path::Path;
Expand All @@ -42,7 +43,7 @@ pub fn generate(output_path: &Path, comment: Option<&str>) -> Result<GeneratedKe
tracing::info!("Generating Ed25519 key pair");

// Generate key pair using cryptographically secure RNG
let keypair = PrivateKey::random(&mut rand::thread_rng(), Algorithm::Ed25519)
let keypair = PrivateKey::random(&mut OsRng, Algorithm::Ed25519)
.context("Failed to generate Ed25519 key")?;

// Get public key and fingerprint
Expand Down
3 changes: 2 additions & 1 deletion src/keygen/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use super::GeneratedKey;
use anyhow::{bail, Context, Result};
use russh::keys::{Algorithm, HashAlg, PrivateKey};
use ssh_key::rand_core::OsRng;
use ssh_key::LineEnding;
use std::io::Write;
use std::path::Path;
Expand Down Expand Up @@ -76,7 +77,7 @@ pub fn generate(output_path: &Path, bits: u32, comment: Option<&str>) -> Result<
// Generate key pair using cryptographically secure RNG
// Use SHA-256 for the RSA signature hash algorithm
let keypair = PrivateKey::random(
&mut rand::thread_rng(),
&mut OsRng,
Algorithm::Rsa {
hash: Some(HashAlg::Sha256),
},
Expand Down
Loading