fix: add timeout for ssh commands
This commit is contained in:
@@ -71,8 +71,12 @@ function save_private_key_for_server(Server $server)
|
||||
|
||||
function generate_ssh_command(string $private_key_location, string $server_ip, string $user, string $port, string $command, bool $isMux = true)
|
||||
{
|
||||
$timeout = config('constants.ssh.command_timeout');
|
||||
$connectionTimeout = config('constants.ssh.connection_timeout');
|
||||
$serverInterval = config('constants.ssh.server_interval');
|
||||
|
||||
$delimiter = 'EOF-COOLIFY-SSH';
|
||||
$ssh_command = "ssh ";
|
||||
$ssh_command = "timeout $timeout ssh ";
|
||||
|
||||
if ($isMux && config('coolify.mux_enabled')) {
|
||||
$ssh_command .= '-o ControlMaster=auto -o ControlPersist=1m -o ControlPath=/var/www/html/storage/app/ssh/mux/%h_%p_%r ';
|
||||
@@ -81,8 +85,8 @@ function generate_ssh_command(string $private_key_location, string $server_ip, s
|
||||
$ssh_command .= "-i {$private_key_location} "
|
||||
. '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '
|
||||
. '-o PasswordAuthentication=no '
|
||||
. '-o ConnectTimeout=3600 '
|
||||
. '-o ServerAliveInterval=20 '
|
||||
. "-o ConnectTimeout=$connectionTimeout "
|
||||
. "-o ServerAliveInterval=$serverInterval "
|
||||
. '-o RequestTTY=no '
|
||||
. '-o LogLevel=ERROR '
|
||||
. "-p {$port} "
|
||||
@@ -90,7 +94,7 @@ function generate_ssh_command(string $private_key_location, string $server_ip, s
|
||||
. " 'bash -se' << \\$delimiter" . PHP_EOL
|
||||
. $command . PHP_EOL
|
||||
. $delimiter;
|
||||
|
||||
ray($ssh_command);
|
||||
return $ssh_command;
|
||||
}
|
||||
function instantCommand(string $command, $throwError = true) {
|
||||
|
Reference in New Issue
Block a user