mirror of
https://github.com/Gu1llaum-3/sshm.git
synced 2026-01-27 03:04:21 +01:00
feat: add remote command execution support (#36)
Allow executing commands on remote hosts via 'sshm <host> <command>'. Add -t/--tty flag for forcing TTY allocation on interactive commands. Co-authored-by: Guillaume Archambault <67098259+Gu1llaum-3@users.noreply.github.com>
This commit is contained in:
36
README.md
36
README.md
@@ -229,6 +229,15 @@ sshm
|
||||
# Connect directly to a specific host (with history tracking)
|
||||
sshm my-server
|
||||
|
||||
# Execute a command on a remote host
|
||||
sshm my-server uptime
|
||||
|
||||
# Execute command with arguments
|
||||
sshm my-server ls -la /var/log
|
||||
|
||||
# Force TTY allocation for interactive commands
|
||||
sshm -t my-server sudo systemctl restart nginx
|
||||
|
||||
# Launch TUI with custom SSH config file
|
||||
sshm -c /path/to/custom/ssh_config
|
||||
|
||||
@@ -286,6 +295,33 @@ sshm web-01
|
||||
- **Error handling** - Clear messages if host doesn't exist or configuration issues
|
||||
- **Config file support** - Works with custom config files using `-c` flag
|
||||
|
||||
### Remote Command Execution
|
||||
|
||||
Execute commands on remote hosts without opening an interactive shell:
|
||||
|
||||
```bash
|
||||
# Execute a single command
|
||||
sshm prod-server uptime
|
||||
|
||||
# Execute command with arguments
|
||||
sshm prod-server ls -la /var/log
|
||||
|
||||
# Check disk usage
|
||||
sshm prod-server df -h
|
||||
|
||||
# View logs (pipe to local commands)
|
||||
sshm prod-server 'cat /var/log/nginx/access.log' | grep 404
|
||||
|
||||
# Force TTY allocation for interactive commands (sudo, vim, etc.)
|
||||
sshm -t prod-server sudo systemctl restart nginx
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- **Exit code propagation** - Remote command exit codes are passed through
|
||||
- **TTY support** - Use `-t` flag for commands requiring terminal interaction
|
||||
- **Pipe-friendly** - Output can be piped to local commands for processing
|
||||
- **History tracking** - Command executions are recorded in connection history
|
||||
|
||||
### Backup Configuration
|
||||
|
||||
SSHM automatically creates backups of your SSH configuration files before making any changes to ensure your configurations are safe.
|
||||
|
||||
Reference in New Issue
Block a user