SSH toolkit for Claude Code agents and humans. One command to set up SSH access, GitHub keys, and server hardening.
pip install paramikoOr install as a CLI tool:
pip install .
auto-ssh-setup --help# Full setup: SSH access + GitHub key in one command
python script.py setup-all --host 1.2.3.4 --user root --password "pass" \
--git-name "Your Name" --git-email "you@example.com"The script will:
- Generate a local ed25519 SSH key (if missing)
- Upload it to the server's
authorized_keys - Generate an SSH key on the server for GitHub
- Configure git on the server
- Print the public key — add it to GitHub SSH keys
python script.py setup-ssh --host 1.2.3.4 --user root --password "pass"After this, password is no longer needed for SSH.
python script.py setup-github --host 1.2.3.4 --user root \
--git-name "Name" --git-email "email@example.com"Generates an SSH key ON the server, configures git, verifies GitHub connectivity. Prints the public key for you to add to GitHub.
python script.py setup-all --host 1.2.3.4 --user root --password "pass" \
--git-name "Name" --git-email "email@example.com"python script.py harden --host 1.2.3.4 --user root
python script.py harden --host 1.2.3.4 --user root --dry-run # preview changesWARNING: This disables password login on the server. The script will refuse to proceed if key-based auth doesn't work yet. Always run setup-ssh first. A backup of sshd_config is created automatically.
| Flag | Description | Default |
|---|---|---|
--host, -H |
Server IP or hostname | required |
--user, -u |
SSH username | required |
--port, -p |
SSH port | 22 |
--password |
SSH password (or use SSH_PASSWORD env var) |
none |
--key-type |
ed25519 or rsa |
ed25519 |
--git-name |
git user.name (setup-github/all) | none |
--git-email |
git user.email (setup-github/all) | none |
--dry-run |
Preview changes without applying (harden) | false |
--version |
Show version | — |
To avoid exposing passwords in shell history / process lists:
# Option 1: env var (recommended)
export SSH_PASSWORD="mypass"
python script.py setup-ssh --host 1.2.3.4 --user root
# Option 2: CLI flag (visible in ps)
python script.py setup-ssh --host 1.2.3.4 --user root --password "mypass"Prefixed lines for easy parsing by AI agents:
[OK]— success[SKIP]— already done (idempotent)[ERROR]— failure (exit code 1)[INFO]— progress[WARN]— non-fatal warning[KEY]— public key output
- All shell arguments are escaped with
shlex.quote()to prevent command injection - Keys are written via SFTP (not
echo >>) to avoid shell interpretation - GitHub host key fingerprint is verified against official published fingerprint
hardencreates a backup ofsshd_configand verifies key auth works before disabling passwords- Duplicate key detection prevents bloating
authorized_keys
- Python 3.8+
ssh-keygenin PATH (pre-installed on Linux/macOS, Windows 10+ with OpenSSH)paramiko(pip install paramiko)
MIT