From b19cabcbfd5fc1a71c47a9bbc287310309c9d762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Wed, 24 Dec 2025 22:09:48 +0800 Subject: [PATCH] fix: Passing null to parameter #5 ($passphrase) of type string is deprecated (#360) --- app/lib/deploy/ssh.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/lib/deploy/ssh.php b/app/lib/deploy/ssh.php index af61df9..bd964c0 100644 --- a/app/lib/deploy/ssh.php +++ b/app/lib/deploy/ssh.php @@ -159,9 +159,14 @@ class ssh implements DeployInterface file_put_contents($privateKeyPath, $this->config['privatekey']); file_put_contents($publicKeyPath, $publicKey); umask($umask); - $passphrase = $this->config['passphrase'] ?? null; // 私钥密码 - if (!ssh2_auth_pubkey_file($connection, $this->config['username'], $publicKeyPath, $privateKeyPath, $passphrase)) { - throw new Exception('私钥认证失败'); + if (!empty($this->config['passphrase'])) { + if (!ssh2_auth_pubkey_file($connection, $this->config['username'], $publicKeyPath, $privateKeyPath, $this->config['passphrase'])) { + throw new Exception('私钥认证失败'); + } + } else { + if (!ssh2_auth_pubkey_file($connection, $this->config['username'], $publicKeyPath, $privateKeyPath)) { + throw new Exception('私钥认证失败'); + } } } else { if (!ssh2_auth_password($connection, $this->config['username'], $this->config['password'])) {