sub _gather_ssh_keys {
my ($self, $user, $home) = @_;
my $ssh_dir = "$home/.ssh";
+ my $ssh_authkeys = "$ssh_dir/authorized_keys";
return {
files => {},
- authorized => { file_name => "$ssh_dir/authorized_keys", body => '' }
+ authorized => { file_name => $ssh_authkeys, body => '' }
} unless -d $ssh_dir;
my %key;
for my $item (files_from_dir $ssh_dir) {
};
};
}
- my $auth_keys = transform_exceptions {
+ my $auth_keys = (-e $ssh_authkeys) ? (transform_exceptions {
return {
- file_name => "$ssh_dir/authorized_keys",
- body => scalar output_from_file "$ssh_dir/authorized_keys",
+ file_name => $ssh_authkeys,
+ body => scalar output_from_file $ssh_authkeys,
};
- };
+ }) : { file_name => $ssh_authkeys, body => '' };
return { files => \%key, authorized => $auth_keys };
}