Skip to content

Commit

Permalink
Merge pull request #154 from vaidasm/hotfix/sftp2
Browse files Browse the repository at this point in the history
Use phpseclib 2 constant
  • Loading branch information
Anton Medvedev committed Jan 30, 2015
2 parents 9141b84 + c321b6b commit ec7dffd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Server/PhpSecLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@

namespace Deployer\Server;

use phpseclib\Crypt\RSA;
use phpseclib\Net\SFTP;

class PhpSecLib extends AbstractServer
{
/**
* @var \Net_SFTP
* @var \phpseclib\Net\SFTP
*/
private $sftp;

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

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

case Configuration::AUTH_BY_PUBLIC_KEY:

$key = new \phpseclib\Crypt\RSA();
$key = new RSA();
$key->setPassword($this->config->getPassPhrase());
$key->loadKey(file_get_contents($this->config->getPrivateKey()));

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

case Configuration::AUTH_BY_PEM_FILE:

$key = new \phpseclib\Crypt\RSA();
$key = new RSA();
$key->loadKey(file_get_contents($this->config->getPemFile()));
if (!$this->sftp->login($this->config->getUser(), $key)) {
throw new \RuntimeException('Could not login with PhpSecLib.');
Expand Down Expand Up @@ -103,7 +106,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 ec7dffd

Please sign in to comment.