From 604098fd50491e9c4506c4098ee2c319119e62b3 Mon Sep 17 00:00:00 2001 From: ziming Date: Wed, 5 Oct 2022 14:06:19 +0800 Subject: [PATCH] Allow private key --- config/remote.php | 5 +++++ src/Commands/RemoteCommand.php | 4 ++++ src/Config/HostConfig.php | 1 + 3 files changed, 10 insertions(+) diff --git a/config/remote.php b/config/remote.php index 9b71ca6..0d2c10a 100644 --- a/config/remote.php +++ b/config/remote.php @@ -28,6 +28,11 @@ * The package will cd to the given path before executing the given command. */ 'path' => env('REMOTE_PATH'), + + /* + * Optional. Path to the private key on your computer if your remote server requires it. + */ + 'private_key_path' => env('REMOTE_PRIVATE_KEY_PATH'), ] ], ]; diff --git a/src/Commands/RemoteCommand.php b/src/Commands/RemoteCommand.php index 2cd6389..ce7503c 100644 --- a/src/Commands/RemoteCommand.php +++ b/src/Commands/RemoteCommand.php @@ -26,6 +26,10 @@ public function handle() }) ->usePort($hostConfig->port); + if ($hostConfig->privateKeyPath) { + $ssh->usePrivateKey($hostConfig->privateKeyPath); + } + $commandsToExecute = $this->getCommandsToExecute($hostConfig); if ($this->failsConfirmationPrompt($hostConfig)) { diff --git a/src/Config/HostConfig.php b/src/Config/HostConfig.php index dc5d489..1a2d29e 100644 --- a/src/Config/HostConfig.php +++ b/src/Config/HostConfig.php @@ -9,6 +9,7 @@ public function __construct( public int $port, public string $user, public string $path, + public ?string $privateKeyPath = null, ) { } }