Skip to content

Commit 936b205

Browse files
Merge branch 'master' of into 5.1
2 parents 009817c + c47d230 commit 936b205

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.idea
44
.env
55
.project
6+
.phpunit.result.cache
67
.settings
78
/backup/*
89
/build/coverage

doc/config/sync/sftp.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"type": "sftp",
33
"options": {
44
"host": "backup.example.com",
5+
"port": "22",
56
"user": "user.name",
67
"password": "mySecret",
78
"key": "someDir/id_rsa",

doc/config/sync/sftp.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<!-- optional, if key presented it is used as key password -->
1010
<option name="password" value="mysecret" />
1111

12+
<!-- optional, default 22 -->
13+
<option name="port" value="22" />
14+
1215
<!-- optional -->
1316
<option name="key" value="somedir/id_rsa" />
1417

src/Backup/Sync/Sftp.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ class Sftp extends Xtp
3434
*/
3535
protected $remotePath;
3636

37+
/**
38+
* Remote port of sftp server
39+
*
40+
* @var string
41+
*/
42+
protected $port;
43+
3744
/**
3845
* @var int
3946
*/
@@ -72,6 +79,7 @@ public function setup(array $config)
7279
}
7380
$this->privateKey = $privateKey;
7481
$this->remotePath = new Path($config['path'], $this->time);
82+
$this->port = Util\Arr::getValue($config, 'port', '22');
7583

7684
$this->setUpCleanable($config);
7785
}
@@ -145,7 +153,7 @@ protected function createClient() : phpseclib\Net\SFTP
145153
if (!$this->sftp) {
146154
// silence phpseclib errors
147155
$old = error_reporting(0);
148-
$this->sftp = new phpseclib\Net\SFTP($this->host);
156+
$this->sftp = new phpseclib\Net\SFTP($this->host, $this->port);
149157
$auth = $this->getAuth();
150158

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

0 commit comments

Comments
 (0)