PHP Deployment Scripts
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.
 
 
neatoDeploy/app/utils/keygen.php

29 lines
1.4 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 ' . safeCmd($file) . ' -N \'' . safeCmd($pwd) . '\' -C \'' . safeCmd($comment) . '\'', $output, $exit_code);
display($output);
checkForError($exit_code, "Unable to run ssh-keygen command: {$file}");
return $exit_code;
}
public static function rsa($file, int $size = 4096, string $pwd = "", string $comment = "") {
$s_size = ($size> 1023 && $size < 9600) ? (string) $size : "4096";
exec(\neato::get_user_bin . 'ssh-keygen -t rsa -b '. safeCmd($s_size) .' -f ' . safeCmd($file) . ' -N \'' . safeCmd($pwd) . '\' -C \'' . safeCmd($comment) . '\'', $output, $exit_code);
display($output);
checkForError($exit_code, "Unable to run ssh-keygen command: {$file}");
return $exit_code;
}
public static function sign(string $host_ca_file, string $file, string $hostname, string $type="-h", string $fqdn = "", string $validfor = "+52w") {
exec(\neato::get_user_bin . 'ssh-keygen -s '. safeCmd($host_ca_file).' -I '. safeCmd($hostname).' '. safeCmd($type).' -n '. safeCmd($fqdn).' -V '. safeCmd($validfor).' '. safeCmd($file), $output, $exit_code);
display($output);
checkForError($exit_code, "Unable to run ssh-keygen command: {$file}");
return $exit_code;
}
}