{$publicKeyPath}"); } function generate_key_pair($path): void { exec("ssh-keygen -t ed25519 -m PEM -N '' -f {$path}"); chmod($path, 0400); } function make_bash_script($commands): string { $script = ''; foreach (preg_split("/((\r?\n)|(\r\n?))/", $commands) as $line) { $script .= 'if ! '.$line."; then\n echo 'VITO_SSH_ERROR' && exit 1 \nfi"."\n"; } return $script; } /** * @throws Exception */ function date_with_timezone($date, $timezone): string { $dt = new DateTime('now', new DateTimeZone($timezone)); $dt->setTimestamp(strtotime($date)); return $dt->format('Y-m-d H:i:s'); }