Allow setting ssh authorized key for root, so pi can be configured via network
Merging changes proposed by Nik LaBelle in merge request #22
This commit is contained in:
parent
c2bc44541a
commit
d2ed03378e
|
@ -24,6 +24,26 @@ if (my $pass = delete($conf->{root_pw})) {
|
|||
close($pipe);
|
||||
}
|
||||
|
||||
if (my $root_authorized_key = delete($conf->{root_authorized_key})) {
|
||||
my $fh;
|
||||
logger('debug', "Adding key to root's authorized_keys");
|
||||
if(! -d "/root/.ssh") {
|
||||
if(!mkdir("/root/.ssh", 0700)) {
|
||||
my $err = sprintf("Could not create /root/.ssh directory: %s", $!);
|
||||
logger('error', $err);
|
||||
die $err;
|
||||
}
|
||||
}
|
||||
|
||||
unless ($fh = IO::File->new('/root/.ssh/authorized_keys', 'w', 0600)) {
|
||||
my $err = $!;
|
||||
logger('error', "Could not write /root/.ssh/authorized_keys: $err");
|
||||
die $err;
|
||||
}
|
||||
$fh->print($root_authorized_key);
|
||||
$fh->close;
|
||||
}
|
||||
|
||||
if (my $name = delete($conf->{hostname})) {
|
||||
my $fh;
|
||||
logger('debug', "Setting hostname to '$name'");
|
||||
|
@ -113,6 +133,9 @@ q(# This file will be automatically evaluated and installed at next boot
|
|||
# for a passwordless login)
|
||||
#root_pw=FooBar
|
||||
|
||||
# root_authorized_key - Set an authorized key for a root ssh login
|
||||
#root_authorized_key=
|
||||
|
||||
# hostname - Set the system hostname.
|
||||
#hostname=rpi
|
||||
));
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
# for a passwordless login)
|
||||
#root_pw=FooBar
|
||||
|
||||
# root_authorized_key - Set an authorized key for a root ssh login
|
||||
#root_authorized_key=
|
||||
|
||||
# hostname - Set the system hostname.
|
||||
#hostname=rpi
|
||||
|
||||
|
|
Loading…
Reference in New Issue