gossh is a command-line tool written in Go that provides a simple and secure way to manage, connect, and execute commands on your SSH servers.
- Connection Management: Add (interactively or via flags), list, remove, and group your SSH connections.
- Remote Command Execution: Execute commands on a server without starting a full interactive session.
- File Transfer: Upload and download files or directories between local and remote hosts using SFTP with visual progress indicators.
- Secure Password Storage: Passwords are encrypted using AES-256 and stored locally.
- Connection Testing: Test connectivity and authentication to a server without a full login.
- Configuration Portability: Export all your connections and credentials to a single file for backup or migration, and import them on another machine.
- Multiple Authentication Methods: Supports password, private key (with passphrase), and interactive password authentication.
- Internationalization (i18n): Supports English (en) and Chinese (zh) languages.
- Prerequisites: Ensure you have Go installed on your system.
- Clone the repository:
git clone https://github.com/your-username/gossh.git cd gossh - Build the executable:
go build -o gossh . - Move the executable to your PATH:
sudo mv gossh /usr/local/bin/
gossh automatically detects your system locale and displays messages in your preferred language if supported.
Language files are embedded in the binary, so you only need the gossh executable - no additional files are required.
gossh reads your system locale from LANG or LANGUAGE environment variables to determine the language to use.
Example on Linux/macOS:
# Set system locale to English (United States)
export LANG=en_US.UTF-8
gossh config list
# Set system locale to Chinese (Simplified)
export LANG=zh_CN.UTF-8
gossh config list- English - Automatically used when your system locale is set to English (en, en_US, en_GB, etc.)
- Chinese (Simplified) - Automatically used when your system locale is set to Chinese (zh, zh_CN, zh_Hans, etc.)
If your system locale is not supported, gossh will fall back to English.
Use the gossh config subcommands to manage your connection configurations.
-
Add a new connection:
gossh config add [flags]
Modes:
- Interactive Mode:
gossh config add -iorgossh config add --interactive - Flag-based Mode:
gossh config add -n <name> -u <user> -H <host> [other-flags...]
Flags:
-i, --interactive: Use interactive mode to add a new connection.-n, --name: The connection name (required in non-interactive mode).-u, --user: The username (required in non-interactive mode).-H, --host: The host address (required in non-interactive mode).-g, --group: Assign the connection to a group.-p, --port: The port number (defaults to 22).-k, --key: Path to the private key.-P, --use-password: Use a saved password by its alias for authentication.
- Interactive Mode:
-
List saved connections:
gossh config list [flags]
Flags:
-g, --group: Filter connections by group name.
-
Remove a connection:
gossh config remove <connection-name>
-
Connect to a server (Interactive Session):
gossh connect <connection-name>
-
Execute a remote command:
gossh exec <connection-name> "<your-command>"
Example:
gossh exec web-server "sudo systemctl status nginx" -
Copy files (Upload/Download):
gossh scp [source] [destination]
Upload (local to remote):
gossh scp /local/file.txt server:/remote/path/ gossh scp -r /local/directory server:/remote/path/ gossh scp -f /local/file.txt server:/remote/path/ # Force overwriteDownload (remote to local):
gossh scp server:/remote/file.txt /local/path/ gossh scp -r server:/remote/directory /local/path/ gossh scp -f server:/remote/file.txt /local/path/ # Force overwriteFlags:
-r, --recursive: Copy directories recursively.-f, --force: Force overwrite of existing files without prompting.
-
Test a connection:
gossh test <connection-name>
This command attempts to authenticate and then immediately disconnects to verify the configuration.
Securely store and manage passwords for your connections.
-
Add a new password:
gossh password add <alias>
You will be prompted to enter the password.
-
List saved password aliases:
gossh password list
-
Remove a password:
gossh password remove <alias>
- List all groups:
gossh groups
-
Export configuration:
gossh config export > gossh_backup.json
This prints all connections and encrypted credentials to standard output.
-
Import configuration:
gossh config import <file-path>
Imports a configuration from a file created by the
exportcommand. Warning: This will overwrite your existing configuration. Flags:-f, --force: Skip the confirmation prompt before overwriting.
Configuration files are stored in ~/.config/gossh/:
config.json: Stores connection configurations.credentials.json: Stores encrypted passwords.secret.key: The encryption key for your passwords.
Note: Do not share your secret.key or credentials.json files as they contain sensitive information.
This project was initiated and guided by pi12138, with development contributions from Qwen and Google's Gemini.