File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -348,14 +348,21 @@ class SFTP extends Server {
348
348
349
349
if (isset($server['sftp_key'])) {
350
350
$key = new Crypt_RSA();
351
+ if (isset($server['pass']) and !empty($server['pass'])) {
352
+ $key->setPassword($server['pass']);
353
+ }
351
354
$key->loadKey(file_get_contents($server['sftp_key']));
352
355
$logged_in = $this->connection->login($server['user'], $key);
356
+
357
+ if (!$logged_in) {
358
+ error("Could not login to {$this->host}. It may be because the key requires a passphrase, which you need to specify it as the 'pass' attribute.");
359
+ }
353
360
} else {
354
361
$logged_in = $this->connection->login($server['user'], $server['pass']);
355
- }
356
-
357
- if (!$logged_in) {
358
- error("Could not login to {$this->host}");
362
+
363
+ if (!$logged_in) {
364
+ error("Could not login to {$this->host}");
365
+ }
359
366
}
360
367
361
368
if (!$this->connection->chdir($server['path'])) {
@@ -640,6 +647,12 @@ class Config {
640
647
$options['pass'] = self::promptPassword();
641
648
}
642
649
650
+ if (isset($options['sftp_key'])) {
651
+ if (substr($options['sftp_key'], 0, 2) == "~/") {
652
+ $options['sftp_key'] = $_SERVER['HOME'].substr($options['sftp_key'], 1);
653
+ }
654
+ }
655
+
643
656
if ($options['skip']) {
644
657
continue;
645
658
} else {
You can’t perform that action at this time.
0 commit comments