You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.3 KiB
28 lines
1.3 KiB
<?php
|
|
|
|
namespace utils;
|
|
|
|
class keygen {
|
|
|
|
public static function ed25519(string $file, string $pwd = "", string $comment = "") {
|
|
exec(\neato::get_user_bin . 'ssh-keygen -t ed25519 -f ' . safe_cmd($file) . ' -N \'' . safe_cmd($pwd) . '\' -C \'' . safe_cmd($comment) . '\'', $output, $exit_code);
|
|
display($output);
|
|
check_for_error($exit_code, "Unable to run ssh-keygen command: {$file}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function rsa($file, int $size = 4096, string $pwd = "", string $comment = "") {
|
|
exec(\neato::get_user_bin . 'ssh-keygen -t rsa -b '. safe_cmd($size) .' -f ' . safe_cmd($file) . ' -N \'' . safe_cmd($pwd) . '\' -C \'' . safe_cmd($comment) . '\'', $output, $exit_code);
|
|
display($output);
|
|
check_for_error($exit_code, "Unable to run ssh-keygen command: {$file}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function sign(string $host_ca_file, string $hostname, string $type="-h", string $fqdn = "", string $validfor = "+52w", string $file) {
|
|
exec(\neato::get_user_bin . 'ssh-keygen -s '. safe_cmd($host_ca_file).' -I '. safe_cmd($hostname).' '. safe_cmd($type).' -n '. safe_cmd($fqdn).' -V '. safe_cmd($validfor).' '. safe_cmd($file), $output, $exit_code);
|
|
display($output);
|
|
check_for_error($exit_code, "Unable to run ssh-keygen command: {$file}");
|
|
return $exit_code;
|
|
}
|
|
|
|
} |