summaryrefslogtreecommitdiff
path: root/setup_session_debian
blob: f96553c31fe2d8ac2e01c4b565fef1bc321887eb (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Usage ./setup_session <pub_key>

chmod a+x stop_hacking_debian
cp stop_hacking_debian /bin/stop_hacking
chmod a+x continue_hacking
cp continue_hacking /bin/continue_hacking
chmod a+x invoke_session_debian
cp invoke_session_debian /bin/invoke_session

if [ $# -ne 1 ]; then
    lava-test-case public-key-installed --result fail
    exit 1
fi

mkdir -p ~/.ssh/
echo $1 >> ~/.ssh/authorized_keys
if [ $? -ne 0 ]; then
    lava-test-case public-key-installed --result fail
fi
chmod 0600 ~/.ssh/authorized_keys
echo "Public Key Installed: $1"
lava-test-case public-key-installed --result pass

# Account for running under sudo
if [ ! -z "${SUDO_USER}" ]; then
    echo "Fixing up ${HOME}/.ssh permissions to ${SUDO_USER}:${SUDO_GID}"
    chown -R ${SUDO_USER}:${SUDO_GID} ${HOME}/.ssh
fi

grep -P "^LogLevel" /etc/ssh/sshd_config
if [ $? -eq 0 ]; then
    sed -i "s/^LogLevel\ [A-Z]\+/LogLevel\ DEBUG/g" /etc/ssh/sshd_config
else
    echo "LogLevel DEBUG" >> /etc/ssh/sshd_config
fi

/etc/init.d/ssh restart
echo "sshd re-started"
if [ $? -eq 0 ]; then
    lava-test-case sshd-restart --result pass
    echo "sshd re-started"
else
    lava-test-case sshd-restart --result fail
    echo "sshd re-start failed"
fi