Skip to content

Commit fd6b232

Browse files
committed
feat: Add SSH configuration file parsing (-F option)
Implements comprehensive SSH config file parsing with support for: - Standard SSH config file reading from ~/.ssh/config or custom path via -F flag - Host pattern matching including wildcards (* and ?) and negation (!) - Over 40 SSH configuration directives including Host, HostName, User, Port, IdentityFile - ProxyJump, ProxyCommand, StrictHostKeyChecking, and connection settings - Proper SSH precedence rules: CLI args > SSH config > defaults - Environment variable expansion in file paths - First-match-wins pattern resolution following SSH behavior The implementation integrates seamlessly with existing bssh commands while maintaining full backward compatibility.
1 parent 9c6be63 commit fd6b232

4 files changed

Lines changed: 1413 additions & 80 deletions

File tree

src/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use std::path::PathBuf;
2121
version,
2222
before_help = "\n\nBackend.AI SSH - Parallel command execution across cluster nodes",
2323
about = "Backend.AI SSH - SSH-compatible parallel command execution tool",
24-
long_about = "bssh is a high-performance SSH client with parallel execution capabilities.\nIt can be used as a drop-in replacement for SSH (single host) or as a powerful cluster management tool (multiple hosts).\n\nThe tool provides secure file transfer using SFTP and supports SSH keys, SSH agent, and password authentication.\nIt automatically detects Backend.AI multi-node session environments.",
25-
after_help = "EXAMPLES:\n SSH Mode:\n bssh user@host # Interactive shell\n bssh admin@server.com \"uptime\" # Execute command\n bssh -p 2222 -i ~/.ssh/key user@host # Custom port and key\n\n Multi-Server Mode:\n bssh -C production \"systemctl status\" # Use cluster config\n bssh -H \"web1,web2,web3\" \"df -h\" # Direct hosts\n\n File Operations:\n bssh -C staging upload file.txt /tmp/ # Upload to cluster\n bssh -H host1,host2 download /etc/hosts ./backups/\n\n Other Commands:\n bssh list # List configured clusters\n bssh -C production ping # Test connectivity\n\nDeveloped and maintained as part of the Backend.AI project.\nFor more information: https://github.com/lablup/bssh"
24+
long_about = "bssh is a high-performance SSH client with parallel execution capabilities.\nIt can be used as a drop-in replacement for SSH (single host) or as a powerful cluster management tool (multiple hosts).\n\nThe tool provides secure file transfer using SFTP and supports SSH keys, SSH agent, and password authentication.\nIt automatically detects Backend.AI multi-node session environments.\n\nSSH Configuration Support:\n- Reads standard SSH config files (defaulting to ~/.ssh/config)\n- Supports Host patterns, HostName, User, Port, IdentityFile, StrictHostKeyChecking\n- ProxyJump, and many other SSH configuration directives\n- CLI arguments override SSH config values following SSH precedence rules",
25+
after_help = "EXAMPLES:\n SSH Mode:\n bssh user@host # Interactive shell\n bssh admin@server.com \"uptime\" # Execute command\n bssh -p 2222 -i ~/.ssh/key user@host # Custom port and key\n bssh -F ~/.ssh/myconfig webserver # Use custom SSH config\n\n Multi-Server Mode:\n bssh -C production \"systemctl status\" # Use cluster config\n bssh -H \"web1,web2,web3\" \"df -h\" # Direct hosts\n bssh -F /etc/ssh/ssh_config -H web* # SSH config with wildcards\n\n File Operations:\n bssh -C staging upload file.txt /tmp/ # Upload to cluster\n bssh -H host1,host2 download /etc/hosts ./backups/\n\n Other Commands:\n bssh list # List configured clusters\n bssh -C production ping # Test connectivity\n\n SSH Config Example (~/.ssh/config):\n Host web*\n HostName web.example.com\n User webuser\n Port 2222\n IdentityFile ~/.ssh/web_key\n StrictHostKeyChecking yes\n\nDeveloped and maintained as part of the Backend.AI project.\nFor more information: https://github.com/lablup/bssh"
2626
)]
2727
pub struct Cli {
2828
/// SSH destination in format: [user@]hostname[:port] or ssh://[user@]hostname[:port]
@@ -137,7 +137,7 @@ pub struct Cli {
137137
short = 'F',
138138
long = "ssh-config",
139139
value_name = "configfile",
140-
help = "Specifies an alternative SSH configuration file"
140+
help = "Specifies an alternative SSH configuration file\nSupports standard SSH config format with Host, HostName, User, Port, IdentityFile, etc.\nDefaults to ~/.ssh/config if not specified and file exists"
141141
)]
142142
pub ssh_config: Option<PathBuf>,
143143

0 commit comments

Comments
 (0)