summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2022-05-06 03:29:42 -0400
committerAndrew Cady <d@jerkface.net>2022-10-09 13:53:09 -0400
commit431eda98ccd397a53fbf2eda9bc9f51502250a95 (patch)
treeb731e550cdf8572fea6192070b5093f4e8f9be76
parent6de4c628eb311ff6a577cca8fad3135e07ccd226 (diff)
remove "penme" commands from this repo
-rwxr-xr-xdot/local/bin/penme44
-rwxr-xr-xdot/local/bin/penyou4
l---------dot/local/bin/sash1
-rwxr-xr-xdot/local/bin/unpenme8
4 files changed, 0 insertions, 57 deletions
diff --git a/dot/local/bin/penme b/dot/local/bin/penme
deleted file mode 100755
index 1a46e6c..0000000
--- a/dot/local/bin/penme
+++ /dev/null
@@ -1,44 +0,0 @@
1#!/bin/sh
2set -e
3if [ "$(id -u)" -ne 0 ]
4then
5 exec sudo -- "$0" "$@"
6fi
7
8vprintf() { [ ! "$VERBOSE" ] || printf "$@" >&2; }
9
10write()
11{
12 printf '%s\n' "$line" >> /root/.ssh/authorized_keys
13 vprintf 'New root authorization: %s\n' "$line"
14 [ "$VERBOSE" ] || printf '%s\n' "$line" >&2
15}
16
17scan_network()
18{
19 arp-scan --localnet |
20 while read ip junk
21 do
22 case "$ip" in
23 *.*.*.*) ;;
24 *) continue ;;
25 esac
26 vprintf 'ARP scan found IP: %s\n' "$ip"
27 ( grep -q " penme host key @ $ip\$" /root/.ssh/authorized_keys ) || echo $ip
28 done
29}
30
31mkdir -p /root/.ssh
32[ -e /root/.ssh/authorized_keys ] || touch /root/.ssh/authorized_keys
33
34which arp-scan >/dev/null &&
35which ssh-keyscan >/dev/null ||
36apt install --no-upgrade arp-scan openssh-client || true
37
38ssh-keyscan - $(scan_network) 2>/dev/null |
39while read ip key
40do
41 line=$(printf '%s penme host key @ %s\n' "$key" "$ip")
42 grep -q -Fx "$line" /root/.ssh/authorized_keys && vprintf 'Already authorized: %s\n' "$line" ||
43 write "$line" /root/.ssh/authorized_keys
44done
diff --git a/dot/local/bin/penyou b/dot/local/bin/penyou
deleted file mode 100755
index cc7fdda..0000000
--- a/dot/local/bin/penyou
+++ /dev/null
@@ -1,4 +0,0 @@
1#!/bin/sh
2sudo=$([ $(id -u) -eq 0 ] || echo sudo --)
3exec $sudo ssh -i /etc/ssh/ssh_host_ed25519_key -l root "$@"
4
diff --git a/dot/local/bin/sash b/dot/local/bin/sash
deleted file mode 120000
index 62f8dc8..0000000
--- a/dot/local/bin/sash
+++ /dev/null
@@ -1 +0,0 @@
1penyou \ No newline at end of file
diff --git a/dot/local/bin/unpenme b/dot/local/bin/unpenme
deleted file mode 100755
index 2759dad..0000000
--- a/dot/local/bin/unpenme
+++ /dev/null
@@ -1,8 +0,0 @@
1#!/bin/sh
2if [ "$(id -u)" -ne 0 ]
3then
4 exec sudo -- "$0" "$@"
5fi
6sedprog='/ penme host key @ [0-9]+\.[0-9].[0-9]+\.[0-9]+/ d'
7FORREALS=-i~penme
8sed ${FORREALS} -E -e "$sedprog" /root/.ssh/authorized_keys