Skip to content

Commit

Permalink
Merge branch 'master' of into 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianfeldmann committed Feb 1, 2019
2 parents 009817c + c47d230 commit 936b205
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.idea
.env
.project
.phpunit.result.cache
.settings
/backup/*
/build/coverage
Expand Down
1 change: 1 addition & 0 deletions doc/config/sync/sftp.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"type": "sftp",
"options": {
"host": "backup.example.com",
"port": "22",
"user": "user.name",
"password": "mySecret",
"key": "someDir/id_rsa",
Expand Down
3 changes: 3 additions & 0 deletions doc/config/sync/sftp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<!-- optional, if key presented it is used as key password -->
<option name="password" value="mysecret" />

<!-- optional, default 22 -->
<option name="port" value="22" />

<!-- optional -->
<option name="key" value="somedir/id_rsa" />

Expand Down
10 changes: 9 additions & 1 deletion src/Backup/Sync/Sftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ class Sftp extends Xtp
*/
protected $remotePath;

/**
* Remote port of sftp server
*
* @var string
*/
protected $port;

/**
* @var int
*/
Expand Down Expand Up @@ -72,6 +79,7 @@ public function setup(array $config)
}
$this->privateKey = $privateKey;
$this->remotePath = new Path($config['path'], $this->time);
$this->port = Util\Arr::getValue($config, 'port', '22');

$this->setUpCleanable($config);
}
Expand Down Expand Up @@ -145,7 +153,7 @@ protected function createClient() : phpseclib\Net\SFTP
if (!$this->sftp) {
// silence phpseclib errors
$old = error_reporting(0);
$this->sftp = new phpseclib\Net\SFTP($this->host);
$this->sftp = new phpseclib\Net\SFTP($this->host, $this->port);
$auth = $this->getAuth();

if (!$this->sftp->login($this->user, $auth)) {
Expand Down

0 comments on commit 936b205

Please sign in to comment.