👌 IMPROVE: add SSH port as possible parameter

Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
This commit is contained in:
Jonas Sulzer
2019-05-22 20:49:00 +02:00
parent 07fddff440
commit 8e1261004c
2 changed files with 8 additions and 6 deletions

View File

@@ -156,14 +156,14 @@ SSH
Authenticates users via SSH. You can use any SSH2 server, but it must accept password authentication.
### Configuration
The only supported parameter is the hostname of the remote machine.
The supported parameters are the hostname and the port (default `22`) of the remote machine.
Add the following to your `config.php`:
'user_backends' => array(
array(
'class' => 'OC_User_SSH',
'arguments' => array('127.0.0.1'),
'arguments' => array('127.0.0.1', '22'),
),
),

View File

@@ -16,18 +16,20 @@
* @link http://github.com/owncloud/apps
*/
class OC_User_SSH extends \OCA\user_external\Base {
private $host;
private $port;
/**
* Create a new SSH authentication provider
*
* @param string $host Hostname or IP address of SSH servr
*/
public function __construct($host) {
public function __construct($host, $port = 22) {
parent::__construct($host);
$this->host =$host;
$this->host = $host;
$this->port = $port;
}
/**
@@ -40,7 +42,7 @@ class OC_User_SSH extends \OCA\user_external\Base {
* @return true/false
*/
public function checkPassword($uid, $password) {
$connection = ssh2_connect($this->host);
$connection = ssh2_connect($this->host, $this->port);
if (ssh2_auth_password($connection, $uid, $password)) {
$this->storeUser($uid);
return $uid;