Skip to content

Commit

Permalink
Update PhpSecLib.php
Browse files Browse the repository at this point in the history
Fix PhpSecLib integration.
  • Loading branch information
Anton Medvedev committed Feb 12, 2015
1 parent 62d968a commit 4e765f9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/Server/Remote/PhpSecLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

use Deployer\Server\Configuration;
use Deployer\Server\ServerInterface;
use phpseclib\Crypt\RSA;
use phpseclib\Net\SFTP;

class PhpSecLib implements ServerInterface
{
Expand All @@ -18,7 +20,7 @@ class PhpSecLib implements ServerInterface
private $configuration;

/**
* @var \Net_SFTP
* @var SFTP
*/
private $sftp;

Expand All @@ -41,11 +43,8 @@ public function __construct(Configuration $configuration)
*/
public function connect()
{
// Fix bug #434 in PhpSecLib
set_include_path(__DIR__ . '/../../vendor/phpseclib/phpseclib/phpseclib/');

$serverConfig = $this->getConfiguration();
$this->sftp = new \Net_SFTP($serverConfig->getHost(), $serverConfig->getPort());
$this->sftp = new SFTP($serverConfig->getHost(), $serverConfig->getPort());

switch ($serverConfig->getAuthenticationMethod()) {
case Configuration::AUTH_BY_PASSWORD:
Expand All @@ -56,7 +55,7 @@ public function connect()

case Configuration::AUTH_BY_PUBLIC_KEY:

$key = new \Crypt_RSA();
$key = new RSA();
$key->setPassword($serverConfig->getPassPhrase());
$key->loadKey(file_get_contents($serverConfig->getPrivateKey()));

Expand All @@ -66,7 +65,7 @@ public function connect()

case Configuration::AUTH_BY_PEM_FILE:

$key = new \Crypt_RSA();
$key = new RSA();
$key->loadKey(file_get_contents($serverConfig->getPemFile()));
$this->sftp->login($serverConfig->getUser(), $key);

Expand Down Expand Up @@ -117,7 +116,7 @@ public function upload($local, $remote)
$this->directories[$dir] = true;
}

if (!$this->sftp->put($remote, $local, NET_SFTP_LOCAL_FILE)) {
if (!$this->sftp->put($remote, $local, SFTP::SOURCE_LOCAL_FILE)) {
throw new \RuntimeException(implode($this->sftp->getSFTPErrors(), "\n"));
}
}
Expand Down

0 comments on commit 4e765f9

Please sign in to comment.