Skip to content

Commit f82c742

Browse files
committed
fix: update default configuration for better user experience
- Change default user from hardcoded 'admin' to current system user - Disable Kerberos by default (changed from true to false) - Add whoami dependency for system user detection - Update all documentation examples to reflect new defaults - Fix clippy linting issues and code formatting - Bump version to 1.1.1 (patch release)
1 parent a190b73 commit f82c742

12 files changed

Lines changed: 256 additions & 85 deletions

File tree

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ All notable changes to Bayesian SSH will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.1] - 2025-08-29
9+
10+
### Fixed
11+
- **Configuration defaults**: Changed default user from hardcoded "admin" to current system user
12+
- **Kerberos default**: Disabled Kerberos by default (changed from `true` to `false`)
13+
- **Documentation**: Updated all examples to reflect new sensible defaults
14+
15+
### Changed
16+
- **Default configuration**: Application now uses current Linux username instead of "admin"
17+
- **Kerberos behavior**: Kerberos authentication is now opt-in rather than default
18+
- **Documentation examples**: Updated configuration commands and JSON examples across all docs
19+
20+
### Technical
21+
- **Dependencies**: Added `whoami` crate for system user detection
22+
- **Configuration**: Updated `AppConfig::default()` implementation
23+
- **Documentation**: Updated README.md, docs/README.md, and docs/advanced-usage.md
24+
825
## [1.1.0] - 2025-08-28
926

1027
### Added

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bayesian-ssh"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
edition = "2021"
55
authors = ["Abdoufermat5"]
66
description = "A fast and lightweight SSH session manager with Kerberos support"
@@ -35,6 +35,7 @@ tracing-subscriber = "0.3"
3535
# Configuration
3636
config = "0.13"
3737
dirs = "5.0"
38+
whoami = "1.5"
3839

3940
# Utilities
4041
chrono = { version = "0.4", features = ["serde"] }

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ The app automatically creates configuration in `~/.config/bayesian-ssh/`:
102102
# View current config
103103
bayesian-ssh config
104104

105-
# Set defaults
106-
bayesian-ssh config --default-user admin --use-kerberos
105+
# Set defaults (Kerberos is disabled by default, current user is used)
106+
bayesian-ssh config --use-kerberos --default-user customuser
107107
```
108108

109109
## 📚 Documentation

docs/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bayesian-ssh list
7171
bayesian-ssh connect "Server Name"
7272

7373
# Connect with custom parameters
74-
bayesian-ssh connect "Server Name" --no-bastion --user admin
74+
bayesian-ssh connect "Server Name" --no-bastion --user customuser
7575

7676
# Show connection details
7777
bayesian-ssh show "Server Name"
@@ -88,8 +88,8 @@ bayesian-ssh remove "Server Name"
8888
# View current configuration
8989
bayesian-ssh config
9090

91-
# Update configuration
92-
bayesian-ssh config --default-user admin --use-kerberos
91+
# Update configuration (Kerberos disabled by default)
92+
bayesian-ssh config --use-kerberos --default-user customuser
9393

9494
# Set default bastion
9595
bayesian-ssh config --default-bastion bastion.company.com
@@ -119,10 +119,10 @@ bayesian-ssh import --file /path/to/ssh/config
119119
### Key Configuration Options
120120
```json
121121
{
122-
"default_user": "admin",
122+
"default_user": "current-system-user",
123123
"default_bastion": "bastion.company.com",
124-
"default_bastion_user": "admin",
125-
"use_kerberos_by_default": true,
124+
"default_bastion_user": "current-system-user",
125+
"use_kerberos_by_default": false,
126126
"log_level": "info",
127127
"auto_save_history": true,
128128
"max_history_size": 1000

docs/advanced-usage.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
```bash
77
# Set up default enterprise configuration
88
bayesian-ssh config \
9-
--default-user admin \
9+
--default-user currentuser \
1010
--default-bastion bastion-server.company.priv \
1111
--use-kerberos
1212

@@ -106,7 +106,7 @@ bayesian-ssh add "DB EC2" ec2-db.company.com \
106106

107107
# Application instance
108108
bayesian-ssh add "App EC2" ec2-app.company.com \
109-
--user admin \
109+
--user currentuser \
110110
--kerberos false \
111111
--key ~/.ssh/ec2-app-key.pem \
112112
--tags ec2,production,application
@@ -143,7 +143,7 @@ bayesian-ssh add "K8s Web Pod" web-pod.namespace.svc.cluster.local \
143143

144144
# Service access
145145
bayesian-ssh add "K8s Service" web-service.namespace.svc.cluster.local \
146-
--user admin \
146+
--user currentuser \
147147
--kerberos false \
148148
--tags kubernetes,service,web
149149
```
@@ -200,12 +200,12 @@ bayesian-ssh add "GCP App" gcp-app.company.com \
200200
```bash
201201
# Primary load balancer
202202
bayesian-ssh add "LB Primary" lb-primary.company.com \
203-
--user admin \
203+
--user currentuser \
204204
--tags loadbalancer,primary,production
205205

206206
# Secondary load balancer
207207
bayesian-ssh add "LB Secondary" lb-secondary.company.com \
208-
--user admin \
208+
--user currentuser \
209209
--tags loadbalancer,secondary,production
210210

211211
# Backend servers
@@ -431,7 +431,7 @@ kinit -f
431431
ssh -t -A -K user@bastion.company.com
432432

433433
# Test with specific bastion user
434-
bayesian-ssh connect "Target Server" --bastion-user admin
434+
bayesian-ssh connect "Target Server" --bastion-user currentuser
435435

436436
# Test bastion port
437437
bayesian-ssh connect "Target Server" --bastion-port 2222

src/cli/commands/connect.rs

Lines changed: 75 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ pub async fn execute(
3737
Ok(_) => return Ok(()), // Exact match found and connected
3838
Err(_) => {
3939
// No exact match, try fuzzy search
40-
info!("No exact match found for '{}', attempting fuzzy search", target);
40+
info!(
41+
"No exact match found for '{}', attempting fuzzy search",
42+
target
43+
);
4144
}
4245
}
4346

@@ -53,14 +56,27 @@ pub async fn execute(
5356
if !recent.is_empty() {
5457
println!("\n📅 Recent connections:");
5558
for (i, conn) in recent.iter().enumerate() {
56-
let last_used = conn.last_used
59+
let last_used = conn
60+
.last_used
5761
.map(|dt| format!(" (last used: {})", format_duration(dt)))
58-
.unwrap_or_else(|| "".to_string());
62+
.unwrap_or_default();
5963
println!(" {}. {}{}", i + 1, conn.name, last_used);
6064
}
6165

62-
if let Some(selection) = interactive_selection(&recent, "Select recent connection")? {
63-
return ssh_service.connect_to_connection(&selection, user, port, kerberos, bastion, no_bastion, bastion_user, key).await;
66+
if let Some(selection) = interactive_selection(&recent, "Select recent connection")?
67+
{
68+
return ssh_service
69+
.connect_to_connection(
70+
&selection,
71+
user,
72+
port,
73+
kerberos,
74+
bastion,
75+
no_bastion,
76+
bastion_user,
77+
key,
78+
)
79+
.await;
6480
}
6581
} else {
6682
println!("No recent connections found.");
@@ -81,23 +97,49 @@ pub async fn execute(
8197
let input = input.trim().to_lowercase();
8298

8399
if matches!(input.as_str(), "y" | "yes") {
84-
return ssh_service.connect_to_connection(conn, user, port, kerberos, bastion, no_bastion, bastion_user, key).await;
100+
return ssh_service
101+
.connect_to_connection(
102+
conn,
103+
user,
104+
port,
105+
kerberos,
106+
bastion,
107+
no_bastion,
108+
bastion_user,
109+
key,
110+
)
111+
.await;
85112
} else {
86113
println!("Connection cancelled.");
87114
return Ok(());
88115
}
89116
}
90117
_ => {
91118
// Multiple matches - interactive selection
92-
println!("🔍 Found {} similar connections for '{}':", matches.len(), target);
119+
println!(
120+
"🔍 Found {} similar connections for '{}':",
121+
matches.len(),
122+
target
123+
);
93124
println!();
94125

95126
for (i, conn) in matches.iter().enumerate() {
96127
print_connection_info(conn, i + 1);
97128
}
98129

99130
if let Some(selection) = interactive_selection(&matches, "Select connection")? {
100-
return ssh_service.connect_to_connection(&selection, user, port, kerberos, bastion, no_bastion, bastion_user, key).await;
131+
return ssh_service
132+
.connect_to_connection(
133+
&selection,
134+
user,
135+
port,
136+
kerberos,
137+
bastion,
138+
no_bastion,
139+
bastion_user,
140+
key,
141+
)
142+
.await;
101143
}
102144
}
103145
}
@@ -112,12 +154,21 @@ fn print_connection_info(connection: &crate::models::Connection, index: usize) {
112154
format!(" [{}]", connection.tags.join(", "))
113155
};
114156

115-
let last_used = connection.last_used
157+
let last_used = connection
158+
.last_used
116159
.map(|dt| format!(" (last used: {})", format_duration(dt)))
117-
.unwrap_or_else(|| "".to_string());
160+
.unwrap_or_default();
118161

119162
println!(" {}. {} ({})", index, connection.name, connection.host);
120-
println!(" Tags: {}{}", if tags_str.is_empty() { "none" } else { &tags_str[1..tags_str.len()-1] }, last_used);
163+
println!(
164+
" Tags: {}{}",
165+
if tags_str.is_empty() {
166+
"none"
167+
} else {
168+
&tags_str[1..tags_str.len() - 1]
169+
},
170+
last_used
171+
);
121172
println!();
122173
}
123174

@@ -148,9 +199,16 @@ fn format_duration(dt: chrono::DateTime<chrono::Utc>) -> String {
148199
}
149200
}
150201

151-
fn interactive_selection(connections: &[crate::models::Connection], prompt: &str) -> Result<Option<crate::models::Connection>> {
202+
fn interactive_selection(
203+
connections: &[crate::models::Connection],
204+
prompt: &str,
205+
) -> Result<Option<crate::models::Connection>> {
152206
loop {
153-
print!("{} [1-{}, 's' to search again, 'q' to quit]: ", prompt, connections.len());
207+
print!(
208+
"{} [1-{}, 's' to search again, 'q' to quit]: ",
209+
prompt,
210+
connections.len()
211+
);
154212
io::stdout().flush()?;
155213

156214
let mut input = String::new();
@@ -184,7 +242,10 @@ fn interactive_selection(connections: &[crate::models::Connection], prompt: &str
184242
if index >= 1 && index <= connections.len() {
185243
return Ok(Some(connections[index - 1].clone()));
186244
} else {
187-
println!("Invalid selection. Please enter a number between 1 and {}.", connections.len());
245+
println!(
246+
"Invalid selection. Please enter a number between 1 and {}.",
247+
connections.len()
248+
);
188249
}
189250
} else {
190251
println!("Invalid input. Please enter a number, 's' to search again, or 'q' to quit.");

src/cli/commands/edit.rs

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ pub async fn execute(
4545
}
4646

4747
// No exact match, try fuzzy search
48-
info!("No exact match found for '{}', attempting fuzzy search", target);
48+
info!(
49+
"No exact match found for '{}', attempting fuzzy search",
50+
target
51+
);
4952

5053
let matches = ssh_service.fuzzy_search(&target, 10).await?;
5154

@@ -58,13 +61,16 @@ pub async fn execute(
5861
if !recent.is_empty() {
5962
println!("\nRecent connections:");
6063
for (i, conn) in recent.iter().enumerate() {
61-
let last_used = conn.last_used
64+
let last_used = conn
65+
.last_used
6266
.map(|dt| format!(" (last: {})", format_duration(dt)))
63-
.unwrap_or_else(|| "".to_string());
67+
.unwrap_or_default();
6468
println!(" {}. {}{}", i + 1, conn.name, last_used);
6569
}
6670

67-
if let Some(selection) = interactive_selection(&recent, "Select connection to edit")? {
71+
if let Some(selection) =
72+
interactive_selection(&recent, "Select connection to edit")?
73+
{
6874
return update_connection(
6975
ssh_service,
7076
selection,
@@ -123,7 +129,11 @@ pub async fn execute(
123129
}
124130
_ => {
125131
// Multiple matches - interactive selection
126-
println!("Found {} similar connections for '{}':", matches.len(), target);
132+
println!(
133+
"Found {} similar connections for '{}':",
134+
matches.len(),
135+
target
136+
);
127137
println!();
128138

129139
for (i, conn) in matches.iter().enumerate() {
@@ -154,6 +164,7 @@ pub async fn execute(
154164
Ok(())
155165
}
156166

167+
#[allow(clippy::too_many_arguments)]
157168
async fn update_connection(
158169
ssh_service: SshService,
159170
mut connection: crate::models::Connection,
@@ -247,12 +258,21 @@ fn print_connection_info(connection: &crate::models::Connection, index: usize) {
247258
format!(" [{}]", connection.tags.join(", "))
248259
};
249260

250-
let last_used = connection.last_used
261+
let last_used = connection
262+
.last_used
251263
.map(|dt| format!(" (last used: {})", format_duration(dt)))
252-
.unwrap_or_else(|| "".to_string());
264+
.unwrap_or_default();
253265

254266
println!(" {}. {} ({})", index, connection.name, connection.host);
255-
println!(" Tags: {}{}", if tags_str.is_empty() { "none" } else { &tags_str[1..tags_str.len()-1] }, last_used);
267+
println!(
268+
" Tags: {}{}",
269+
if tags_str.is_empty() {
270+
"none"
271+
} else {
272+
&tags_str[1..tags_str.len() - 1]
273+
},
274+
last_used
275+
);
256276
println!();
257277
}
258278

@@ -283,9 +303,16 @@ fn format_duration(dt: chrono::DateTime<chrono::Utc>) -> String {
283303
}
284304
}
285305

286-
fn interactive_selection(connections: &[crate::models::Connection], prompt: &str) -> Result<Option<crate::models::Connection>> {
306+
fn interactive_selection(
307+
connections: &[crate::models::Connection],
308+
prompt: &str,
309+
) -> Result<Option<crate::models::Connection>> {
287310
loop {
288-
print!("{} [1-{}, 's' to search again, 'q' to quit]: ", prompt, connections.len());
311+
print!(
312+
"{} [1-{}, 's' to search again, 'q' to quit]: ",
313+
prompt,
314+
connections.len()
315+
);
289316
io::stdout().flush()?;
290317

291318
let mut input = String::new();
@@ -318,7 +345,10 @@ fn interactive_selection(connections: &[crate::models::Connection], prompt: &str
318345
if index >= 1 && index <= connections.len() {
319346
return Ok(Some(connections[index - 1].clone()));
320347
} else {
321-
println!("Invalid selection. Please enter a number between 1 and {}.", connections.len());
348+
println!(
349+
"Invalid selection. Please enter a number between 1 and {}.",
350+
connections.len()
351+
);
322352
}
323353
} else {
324354
println!("Invalid input. Please enter a number, 's' to search again, or 'q' to quit.");

0 commit comments

Comments
 (0)