static usb ethnet addresses
[automated-distro-installer] / fai / config / scripts / FAIBASE / 15-root-ssh-key
1 #! /bin/bash
2
3 # (c) Thomas Lange, 2022, lange@debian.org
4 #
5 # Add public ssh key for user root to get login access
6
7 error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
8
9 SSHDIR=$target/root/.ssh
10 AUKEY=$SSHDIR/authorized_keys
11
12 # reverse order of classes
13 for c in $classes; do
14 revclasses="$c $revclasses"
15 done
16
17 for c in $revclasses; do
18 if [ -f $FAI/files/root-ssh-key/$c ]; then
19 if [ -f $AUKEY ]; then
20 cmp -s $FAI/files/root-ssh-key/$c $AUKEY
21 if [ $? -eq 0 ]; then
22 exit
23 fi
24 fi
25 if [ ! -d $SSHDIR ]; then
26 mkdir -m 700 $SSHDIR
27 fi
28 cp -v $FAI/files/root-ssh-key/$c $AUKEY
29 chown root:root $AUKEY
30 chmod 700 $AUKEY
31 break
32 fi
33 done
34
35 exit $error