Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to run ssh commands to localhost #561

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
"Castor\\Tests\\": "tests/"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/pierrelemee/ssh"
}
],
"require": {
"php": ">=8.1",
"composer/composer": "^2.8.2",
Expand All @@ -40,7 +46,7 @@
"monolog/monolog": "^3.7",
"nikic/php-parser": "^v5.3.1",
"phpstan/phpdoc-parser": "^1.33",
"spatie/ssh": "^1.12.0",
"spatie/ssh": "dev-feature/105-local-ssh",
"symfony/cache": "^6.4.14",
"symfony/config": "^6.4.14",
"symfony/console": "^6.4.14",
Expand Down
41 changes: 24 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/Runner/SshRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
): Ssh {
$ssh = Ssh::create($user, $host, $sshOptions['port'] ?? null);

if ($sshOptions['no_bash'] ?? false) {

Check failure on line 105 in src/Runner/SshRunner.php

View workflow job for this annotation

GitHub Actions / Static Analysis

If condition is always false.

Check failure on line 105 in src/Runner/SshRunner.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Offset 'no_bash' on array{port?: int, path_private_key?: string, jump_host?: string, multiplexing_control_path?: string, multiplexing_control_persist?: string, enable_strict_check?: bool, password_authentication?: bool} on left side of ?? does not exist.
$ssh->removeBash();
}

if ($sshOptions['path_private_key'] ?? false) {
$ssh->usePrivateKey($sshOptions['path_private_key']);
}
Expand All @@ -111,13 +115,17 @@
if ($sshOptions['multiplexing_control_path'] ?? false) {
$ssh->useMultiplexing($sshOptions['multiplexing_control_path'], $sshOptions['multiplexing_control_persist'] ?? '10m');
}
if ($sshOptions['enable_strict_check'] ?? false) {
if (isset($sshOptions['enable_strict_check'])) {
$sshOptions['enable_strict_check'] ? $ssh->enableStrictHostKeyChecking() : $ssh->disableStrictHostKeyChecking();
}
if ($sshOptions['password_authentication'] ?? false) {
if (isset($sshOptions['password_authentication'])) {
$sshOptions['password_authentication'] ? $ssh->enablePasswordAuthentication() : $ssh->disablePasswordAuthentication();
}

if ($sshOptions['allow_local_connection'] ?? false) {

Check failure on line 125 in src/Runner/SshRunner.php

View workflow job for this annotation

GitHub Actions / Static Analysis

If condition is always false.

Check failure on line 125 in src/Runner/SshRunner.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Offset 'allow_local…' on array{port?: int, path_private_key?: string, jump_host?: string, multiplexing_control_path?: string, multiplexing_control_persist?: string, enable_strict_check?: bool, password_authentication?: bool} on left side of ?? does not exist.
$ssh->allowLocalConnection();
}

return $ssh;
}
}
Loading