feat: ssh-agent instead of filesystem based ssh keys
This commit is contained in:
@@ -73,7 +73,7 @@ class RunRemoteProcess
|
||||
$this->time_start = hrtime(true);
|
||||
|
||||
$status = ProcessStatus::IN_PROGRESS;
|
||||
$processResult = Process::forever()->run($this->getCommand(), $this->handleOutput(...));
|
||||
$processResult = processWithEnv()->forever()->run($this->getCommand(), $this->handleOutput(...));
|
||||
|
||||
if ($this->activity->properties->get('status') === ProcessStatus::ERROR->value) {
|
||||
$status = ProcessStatus::ERROR;
|
||||
@@ -104,11 +104,10 @@ class RunRemoteProcess
|
||||
{
|
||||
$user = $this->activity->getExtraProperty('user');
|
||||
$server_ip = $this->activity->getExtraProperty('server_ip');
|
||||
$private_key_location = $this->activity->getExtraProperty('private_key_location');
|
||||
$port = $this->activity->getExtraProperty('port');
|
||||
$command = $this->activity->getExtraProperty('command');
|
||||
|
||||
return generate_ssh_command($private_key_location, $server_ip, $user, $port, $command);
|
||||
return generateSshCommand($server_ip, $user, $port, $command);
|
||||
}
|
||||
|
||||
protected function handleOutput(string $type, string $output)
|
||||
|
||||
@@ -13,7 +13,6 @@ class CoolifyTaskArgs extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $server_ip,
|
||||
public string $private_key_location,
|
||||
public string $command,
|
||||
public int $port,
|
||||
public string $user,
|
||||
|
||||
@@ -14,6 +14,7 @@ class ShowPrivateKey extends Component
|
||||
public function setPrivateKey($newPrivateKeyId)
|
||||
{
|
||||
try {
|
||||
refresh_server_connection($this->server->privateKey);
|
||||
$oldPrivateKeyId = $this->server->private_key_id;
|
||||
$this->server->update([
|
||||
'private_key_id' => $newPrivateKeyId
|
||||
@@ -26,7 +27,7 @@ class ShowPrivateKey extends Component
|
||||
'private_key_id' => $oldPrivateKeyId
|
||||
]);
|
||||
$this->server->refresh();
|
||||
refresh_server_connection($this->server->privateKey);
|
||||
refresh_server_connection($this->server->privateKey);
|
||||
return general_error_handler($e, that: $this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,8 @@ trait ExecuteRemoteCommand
|
||||
$ip = data_get($this->server, 'ip');
|
||||
$user = data_get($this->server, 'user');
|
||||
$port = data_get($this->server, 'port');
|
||||
$private_key_location = get_private_key_for_server($this->server);
|
||||
|
||||
$commandsText->each(function ($single_command) use ($private_key_location, $ip, $user, $port) {
|
||||
$commandsText->each(function ($single_command) use ($ip, $user, $port) {
|
||||
$command = data_get($single_command, 'command') ?? $single_command[0] ?? null;
|
||||
if ($command === null) {
|
||||
throw new \RuntimeException('Command is not set');
|
||||
@@ -39,8 +38,8 @@ trait ExecuteRemoteCommand
|
||||
$ignore_errors = data_get($single_command, 'ignore_errors', false);
|
||||
$this->save = data_get($single_command, 'save');
|
||||
|
||||
$remote_command = generate_ssh_command($private_key_location, $ip, $user, $port, $command);
|
||||
$process = Process::timeout(3600)->idleTimeout(3600)->start($remote_command, function (string $type, string $output) use ($command, $hidden) {
|
||||
$remote_command = generateSshCommand( $ip, $user, $port, $command);
|
||||
$process = processWithEnv()->timeout(3600)->idleTimeout(3600)->start($remote_command, function (string $type, string $output) use ($command, $hidden) {
|
||||
$output = Str::of($output)->trim();
|
||||
$new_log_entry = [
|
||||
'command' => $command,
|
||||
|
||||
Reference in New Issue
Block a user