ssh
remote.ssh
Protects against destructive SSH operations like remote command execution and key management.
- 6blocking rules
- 9safe patterns
- 2Critical
- 2High
- 2Medium
[packs]
enabled = ["remote.ssh"]Evaluated when a command contains ssh, ssh-keygen, ssh-keyscan.
Blocking rules
Each rule ID is remote.ssh:<name>. Use it in allowlists and [policy.rules].
Criticalssh-remote-rm-rfSSH remote execution contains destructive rm -rf command.
Explanation
Executing rm -rf on a remote system via SSH can cause irreversible data loss. Remote systems often have different directory structures and you may not have the same safety mechanisms in place. Safer alternatives: - SSH in and run commands interactively with confirmation - Use --dry-run or preview flags when available - Ensure backups exist on the remote system
Criticalssh-remote-sudo-rmSSH remote execution with sudo rm is high-risk.
Explanation
Executing sudo rm on a remote system bypasses normal permission restrictions and can delete system files. Combined with SSH, there's no interactive confirmation and errors may not be visible. Safer alternatives: - SSH in and run sudo commands interactively - Use mv to a backup location instead of rm - Implement proper cleanup scripts with safety checks
Highssh-remote-git-cleanSSH remote execution contains destructive git clean -f command.
Explanation
Running git clean -f on a remote server permanently removes untracked files. This might delete logs, uploads, or configuration files that were never committed to the repository. Safer alternatives: - Run git clean -n first to preview what would be deleted - Use .gitignore to protect important untracked files - Back up untracked files before cleaning
Highssh-remote-git-reset-hardSSH remote execution contains destructive git reset --hard command.
Explanation
Running git reset --hard on a remote server discards all uncommitted changes. On production servers, this might destroy deployment state or configuration changes made directly on the server. Safer alternatives: - git stash on the remote first to save changes - Use git status remotely to check for uncommitted work - Consider proper deployment pipelines instead of direct remote git
Mediumssh-add-delete-allssh-add -d/-D removes identities from the SSH agent.
Explanation
Removing SSH identities from the agent will require re-authentication for subsequent connections. Using -D removes ALL identities, which may interrupt active sessions or scripts. Safer alternatives: - Use -d to remove specific keys rather than -D for all - List keys with ssh-add -l before removing - Re-add keys immediately if needed
Mediumssh-keygen-remove-hostssh-keygen -R removes entries from known_hosts file.
Explanation
Removing entries from known_hosts weakens protection against man-in-the-middle attacks. The next connection will trust any key presented by the remote host. Safer alternatives: - Verify the new host key fingerprint before removing old entry - Use ssh-keyscan to preview the new key - Update entry rather than removing (add new key, then remove old)
Safe patterns
Checked first. A command that matches one is never blocked by this pack.
ssh-versionssh-version-longssh-keygen-listssh-keygen-fingerprintssh-keyscanssh-add-listssh-agentssh-helpssh-keygen-help