libreschool-pxeserver/root/etc/e-smith/templates/srv/ipxe/success_script.sh/50SSHKey

23 lines
527 B
Plaintext
Raw Normal View History

2020-03-29 16:21:43 +00:00
#
# 50SSHKey
#
{
use esmith::ConfigDB;
my $configdb = esmith::ConfigDB->open();
$keyfile = $configdb->get('client-manager')->prop('ManagementKeyFile')
or die "cannot get ManagementKeyFile value";
my $sshkey;
open(my $fh, '<', $keyfile) or die "cannot open file $keyfile";
{
local $/;
$sshkey = <$fh>;
}
close($fh);
$OUT .= "mkdir -p /root/.ssh\n";
$OUT .= "cat >/root/.ssh/authorized_keys <<EOF\n$sshkey\nEOF\n";
$OUT .= "chmod -R go-rwx /root/.ssh\n";
}