This commit is contained in:
Jamie Cameron
2022-09-17 16:40:12 -07:00
parent 339ec2178a
commit 2bc8def078
2 changed files with 15 additions and 5 deletions

View File

@ -377,5 +377,16 @@ return &ui_radio($name, lc($value) eq 'yes' ? 1 :
[ 2, $text{'default'} ] ]);
}
sub get_preferred_key_type
{
if ($version{'type'} eq 'openssh' && $version{'number'} >= 6.5) {
return "ed25519";
}
if ($version{'type'} eq 'openssh' && $version{'number'} >= 3.2) {
return "rsa1";
}
return undef;
}
1;

View File

@ -9,15 +9,14 @@ my ($uinfo) = @_;
if ($config{'sync_create'} && &has_command($config{'keygen_path'}) &&
-d $uinfo->{'home'} && !-d "$uinfo->{'home'}/.ssh") {
local $cmd;
local $type = $config{'sync_type'} ? "-t $config{'sync_type'}" :
$version{'type'} eq 'openssh' &&
$version{'number'} >= 3.2 ? "-t rsa1" : "";
local $type = $config{'sync_type'} || &get_preferred_key_type();
local $tflag = $type ? "-t $type" : "";
if ($config{'sync_pass'} && $uinfo->{'passmode'} == 3) {
$cmd = "$config{'keygen_path'} $type -P ".
$cmd = "$config{'keygen_path'} $tflag -P ".
quotemeta($uinfo->{'plainpass'});
}
else {
$cmd = "$config{'keygen_path'} $type -P \"\"";
$cmd = "$config{'keygen_path'} $tflag -P \"\"";
}
&system_logged("echo '' | ".&command_as_user($uinfo->{'user'}, 0, $cmd).
" >/dev/null 2>&1");