summaryrefslogtreecommitdiff
path: root/delkey
blob: fcb858cd80808beecc795903c7f5c51a0171226b (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
# Delete an authorized_keys entry. Specify the line number (from catkeys) to delete.

if [ $# -ne 1 ]; then
	echo "Syntax: $0 <line number>" >&2
	exit 1
fi

line_no="$1"

if ! [[ $line_no =~ ^[0-9]+$ ]]; then
	echo "Argument must be a number" >&2
	exit 1
fi

sed -i "$line_no"d "$HOME/.ssh/authorized_keys"

echo "New keys:"
cat -n "$HOME/.ssh/authorized_keys"