Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
350f8eb8
Commit
350f8eb8
authored
10 years ago
by
SA
Committed by
Lukas Reschke
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add support for sftp custom port
parent
e08ebe87
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files_external/lib/sftp.php
+15
-3
15 additions, 3 deletions
apps/files_external/lib/sftp.php
with
15 additions
and
3 deletions
apps/files_external/lib/sftp.php
+
15
−
3
View file @
350f8eb8
...
...
@@ -37,6 +37,7 @@ class SFTP extends \OC\Files\Storage\Common {
private
$user
;
private
$password
;
private
$root
;
private
$port
=
22
;
/**
* @var \Net_SFTP
...
...
@@ -50,10 +51,21 @@ class SFTP extends \OC\Files\Storage\Common {
\Net_SFTP_Stream
::
register
();
$this
->
host
=
$params
[
'host'
];
//deals with sftp://server example
$proto
=
strpos
(
$this
->
host
,
'://'
);
if
(
$proto
!=
false
)
{
$this
->
host
=
substr
(
$this
->
host
,
$proto
+
3
);
}
//deals with server:port
$HasPort
=
strpos
(
$this
->
host
,
':'
);
if
(
$HasPort
!=
false
)
{
$pieces
=
explode
(
":"
,
$this
->
host
);
$this
->
host
=
$pieces
[
0
];
$this
->
port
=
$pieces
[
1
];
}
$this
->
user
=
$params
[
'user'
];
$this
->
password
=
isset
(
$params
[
'password'
])
?
$params
[
'password'
]
:
''
;
...
...
@@ -81,7 +93,7 @@ class SFTP extends \OC\Files\Storage\Common {
}
$hostKeys
=
$this
->
readHostKeys
();
$this
->
client
=
new
\Net_SFTP
(
$this
->
host
);
$this
->
client
=
new
\Net_SFTP
(
$this
->
host
,
$this
->
port
);
// The SSH Host Key MUST be verified before login().
$currentHostKey
=
$this
->
client
->
getServerPublicHostKey
();
...
...
@@ -112,7 +124,7 @@ class SFTP extends \OC\Files\Storage\Common {
}
public
function
getId
(){
return
'sftp::'
.
$this
->
user
.
'@'
.
$this
->
host
.
'/'
.
$this
->
root
;
return
'sftp::'
.
$this
->
user
.
'@'
.
$this
->
host
.
':'
.
$this
->
port
.
'/'
.
$this
->
root
;
}
public
function
getHost
()
{
...
...
@@ -342,7 +354,7 @@ class SFTP extends \OC\Files\Storage\Common {
// Do not pass the password here. We want to use the Net_SFTP object
// supplied via stream context or fail. We only supply username and
// hostname because this might show up in logs (they are not used).
$url
=
'sftp://'
.
$this
->
user
.
'@'
.
$this
->
host
.
$this
->
root
.
$path
;
$url
=
'sftp://'
.
$this
->
user
.
'@'
.
$this
->
host
.
':'
.
$this
->
port
.
$this
->
root
.
$path
;
return
$url
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment