From 8e1261004ce399d72b078d44f8899a7d93fcec7f Mon Sep 17 00:00:00 2001 From: Jonas Sulzer Date: Wed, 22 May 2019 20:49:00 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20add=20SSH=20port=20as?= =?UTF-8?q?=20possible=20parameter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonas Sulzer --- README.md | 4 ++-- lib/ssh.php | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 98ffa07..4d11c1b 100644 --- a/README.md +++ b/README.md @@ -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'), ), ), diff --git a/lib/ssh.php b/lib/ssh.php index ae575ba..6948645 100644 --- a/lib/ssh.php +++ b/lib/ssh.php @@ -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;