summaryrefslogtreecommitdiff
path: root/global/post-tasks.d/010fix-ssh-perms
blob: 87636d79dd70d0bb004a67df7fb17d5c084ec33b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
#
# Re-used example from SJD
#

if test -d /root/.ssh && \
    test `stat -t /root/.ssh | cut -d\  -f5` != 0; then
    chown root.root /root/.ssh
fi

if test -d /root/.ssh && \
    test `stat -c %a /root/.ssh` != 700; then
    chmod 700 /root/.ssh
fi

if test -f /root/.ssh/authorized_keys; then
    if test `stat -t /root/.ssh/authorized_keys | cut -d\  -f5` != 0; then
	chown root.root /root/.ssh/authorized_keys
    fi
    if test `stat --printf=%a /root/.ssh/authorized_keys` != 600; then
	chmod 600 /root/.ssh/authorized_keys
    fi
fi