Skip to content

Commit 6be496b

Browse files
committed
[Filemanager] Auto-detect sftp port number (Default 22)
1 parent 285f9b0 commit 6be496b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

install/deb/filemanager/filegator/configuration.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,17 @@
2121
exec ("sudo /usr/local/hestia/bin/v-add-user-sftp-key " . escapeshellarg(basename($v_user)) . " 30", $output, $return_var);
2222
}
2323

24+
if ( !isset($_SESSION['SFTP_PORT']) ) {
25+
if( preg_match('/^\s*Port\s+(\d+)$/im', file_get_contents('/etc/ssh/sshd_config'), $matches) ) {
26+
$_SESSION['SFTP_PORT'] = $matches[1] ?? 22;
27+
} else {
28+
$_SESSION['SFTP_PORT'] = 22;
29+
}
30+
}
31+
2432
return new \League\Flysystem\Sftp\SftpAdapter([
2533
'host' => '127.0.0.1',
26-
'port' => 22,
34+
'port' => intval($_SESSION['SFTP_PORT']),
2735
'username' => basename($v_user),
2836
'privateKey' => '/home/'.basename($v_user).'/.ssh/hst-filemanager-key',
2937
'root' => '/',

0 commit comments

Comments
 (0)