-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenable_insecure_key
executable file
·30 lines (26 loc) · 1.31 KB
/
enable_insecure_key
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
set -e
AUTHORIZED_KEYS=/home/paul/.ssh/authorized_keys
if [[ -e "$AUTHORIZED_KEYS" ]] && grep -q baseimage-docker-insecure-key "$AUTHORIZED_KEYS"; then
echo "Insecure key has already been added to $AUTHORIZED_KEYS."
else
DIR=`dirname "$AUTHORIZED_KEYS"`
echo "Creating directory $DIR..."
mkdir -p "$DIR"
chmod 700 "$DIR"
chown "$1":"$1" "$DIR"
echo "Editing $AUTHORIZED_KEYS..."
cat /etc/insecure_key.pub >> "$AUTHORIZED_KEYS"
echo "Success: insecure key has been added to $AUTHORIZED_KEYS"
cat <<-EOF
+------------------------------------------------------------------------------+
| Insecure SSH key installed |
| |
| DO NOT expose port 22 on the Internet unless you know what you are doing! |
| |
| Use the private key below to connect |
+------------------------------------------------------------------------------+
EOF
cat /etc/insecure_key
echo -e "\n\n"
fi