Skip to content

Commit ec7dffd

Browse files
author
Anton Medvedev
committed
Merge pull request #154 from vaidasm/hotfix/sftp2
Use phpseclib 2 constant
2 parents 9141b84 + c321b6b commit ec7dffd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Server/PhpSecLib.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77

88
namespace Deployer\Server;
99

10+
use phpseclib\Crypt\RSA;
11+
use phpseclib\Net\SFTP;
12+
1013
class PhpSecLib extends AbstractServer
1114
{
1215
/**
13-
* @var \Net_SFTP
16+
* @var \phpseclib\Net\SFTP
1417
*/
1518
private $sftp;
1619

@@ -25,7 +28,7 @@ class PhpSecLib extends AbstractServer
2528
*/
2629
public function connect()
2730
{
28-
$this->sftp = new \phpseclib\Net\SFTP($this->config->getHost(), $this->config->getPort());
31+
$this->sftp = new SFTP($this->config->getHost(), $this->config->getPort());
2932

3033
switch ($this->config->getAuthenticationMethod()) {
3134
case Configuration::AUTH_BY_PASSWORD:
@@ -38,7 +41,7 @@ public function connect()
3841

3942
case Configuration::AUTH_BY_PUBLIC_KEY:
4043

41-
$key = new \phpseclib\Crypt\RSA();
44+
$key = new RSA();
4245
$key->setPassword($this->config->getPassPhrase());
4346
$key->loadKey(file_get_contents($this->config->getPrivateKey()));
4447

@@ -50,7 +53,7 @@ public function connect()
5053

5154
case Configuration::AUTH_BY_PEM_FILE:
5255

53-
$key = new \phpseclib\Crypt\RSA();
56+
$key = new RSA();
5457
$key->loadKey(file_get_contents($this->config->getPemFile()));
5558
if (!$this->sftp->login($this->config->getUser(), $key)) {
5659
throw new \RuntimeException('Could not login with PhpSecLib.');
@@ -103,7 +106,7 @@ public function upload($local, $remote)
103106
$this->directories[$dir] = true;
104107
}
105108

106-
if (!$this->sftp->put($remote, $local, NET_SFTP_LOCAL_FILE)) {
109+
if (!$this->sftp->put($remote, $local, SFTP::SOURCE_LOCAL_FILE)) {
107110
throw new \RuntimeException(implode($this->sftp->getSFTPErrors(), "\n"));
108111
}
109112
}

0 commit comments

Comments
 (0)