Skip to content

Instantly share code, notes, and snippets.

View AnthillBeetle's full-sized avatar

AnthillBeetle

View GitHub Profile
@AnthillBeetle
AnthillBeetle / remember_command
Last active March 6, 2017 22:18
Remember first requested command for the SSH key and refuse to run if command changes.
#!/bin/bash
set -euo pipefail
if [[ $# -ne 1 ]] || [[ "$1" == '--help' ]]; then
cat >&2 <<'EOF'
Insert the following before a key in .ssh/authorized_keys:
command=".ssh/remember_command ID",no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc,no-pty
(On newer systems you can replace all these no-* options with single "restrict".)
Put this script into your ~/.ssh/ directory and make it executable.
It will remember the first requested command for the specified ID,