diff --git a/interface/web/tools/form/user_settings.tform.php b/interface/web/tools/form/user_settings.tform.php
index 516031a18de5c813799c46d2ced3f50794e03f8e..df3f5a8675471e2085c0168055d4a49e71ca5f47 100644
--- a/interface/web/tools/form/user_settings.tform.php
+++ b/interface/web/tools/form/user_settings.tform.php
@@ -133,6 +133,26 @@ $form['tabs']['users'] = array (
'maxlength' => '2',
'rows' => '',
'cols' => ''
+ ),
+ 'id_rsa' => array (
+ 'datatype' => 'VARCHAR',
+ 'formtype' => 'TEXT',
+ 'default' => '',
+ 'datasource' => array ( 'type' => 'SQL',
+ 'querystring' => 'SELECT id_rsa FROM sys_user WHERE {AUTHSQL}',
+ 'valuefield'=> 'id_rsa'
+ ),
+ 'value' => ''
+ ),
+ 'ssh_rsa' => array (
+ 'datatype' => 'VARCHAR',
+ 'formtype' => 'TEXT',
+ 'default' => '',
+ 'datasource' => array ( 'type' => 'SQL',
+ 'querystring' => 'SELECT ssh_rsa FROM sys_user WHERE {AUTHSQL}',
+ 'valuefield'=> 'ssh_rsa'
+ ),
+ 'value' => ''
)
##################################
# ENDE Datenbankfelder
@@ -141,4 +161,4 @@ $form['tabs']['users'] = array (
);
-?>
\ No newline at end of file
+?>
diff --git a/interface/web/tools/lib/lang/de_usersettings.lng b/interface/web/tools/lib/lang/de_usersettings.lng
index 28b1f74e9c43a8234c410357ef9cd3814516b156..1791b71dec007092a299b438cb3ebb8acbbbbf2d 100644
--- a/interface/web/tools/lib/lang/de_usersettings.lng
+++ b/interface/web/tools/lib/lang/de_usersettings.lng
@@ -3,6 +3,6 @@ $wb['passwort_txt'] = 'Passwort';
$wb['language_txt'] = 'Sprache';
$wb['password_mismatch'] = 'Die Passwörter stimmen nicht überein.';
$wb['password_strength_txt'] = 'Passwortkomplexität';
-$wb['Form to edit the user password and language.'] = 'Formular, um das Benutzerpasswort und die Sprache zu bearbeiten.';
+$wb['Form to edit the user password and language.'] = 'Formular, um das Benutzerpasswort, die Sprache und die authentication zu bearbeiten.';
$wb['Settings'] = 'Einstellungen';
?>
diff --git a/interface/web/tools/lib/lang/en_usersettings.lng b/interface/web/tools/lib/lang/en_usersettings.lng
index bfe487113b715886e4e5511818ab9c4b0a55ee76..4169e8cce2d5a027a767d72ee4db7c5a07ec5932 100644
--- a/interface/web/tools/lib/lang/en_usersettings.lng
+++ b/interface/web/tools/lib/lang/en_usersettings.lng
@@ -3,6 +3,6 @@ $wb["passwort_txt"] = 'Password';
$wb["password_strength_txt"] = 'Password strength';
$wb["language_txt"] = 'Language';
$wb["password_mismatch"] = 'The password in the second password field does not match the first password.';
-$wb["Form to edit the user password and language."] = 'Form to edit the user password and language.';
+$wb["Form to edit the user password and language."] = 'Form to edit the user password, language, and authentication.';
$wb["Settings"] = 'Settings';
?>
diff --git a/interface/web/tools/lib/lang/hu_usersettings.lng b/interface/web/tools/lib/lang/hu_usersettings.lng
index 89dc62835e8dc4f87c7d0fc50a69a9e69a90b215..d9cc0bf9d11b11233e0782cbd11efc4843ebdd98 100644
--- a/interface/web/tools/lib/lang/hu_usersettings.lng
+++ b/interface/web/tools/lib/lang/hu_usersettings.lng
@@ -2,7 +2,7 @@
$wb['passwort_txt'] = 'Jelszó';
$wb['language_txt'] = 'Nyelv';
$wb['password_mismatch'] = 'Jelszavak nem egyeznek meg.';
-$wb['Form to edit the user password and language.'] = 'Jelszó és nyelv beállító oldal.';
+$wb['Form to edit the user password and language.'] = 'Jelszó, nyelv és hitelesítés beállító oldal.';
$wb['Settings'] = 'Beállítások';
$wb['password_strength_txt'] = 'Jelszó erősség';
?>
diff --git a/interface/web/tools/templates/user_settings.htm b/interface/web/tools/templates/user_settings.htm
index 658b94fafff7f7254e1d267998acb8967291aa35..a3202adb7763350435f0155173f3915cc02579ec 100644
--- a/interface/web/tools/templates/user_settings.htm
+++ b/interface/web/tools/templates/user_settings.htm
@@ -24,6 +24,14 @@
{tmpl_var name='language'}
+
+
+
+
+
+
+
+
diff --git a/server/plugins-available/shelluser_base_plugin.inc.php b/server/plugins-available/shelluser_base_plugin.inc.php
index 69348f58f04bf2b237873e07a58d6018124ca221..22c5f5f4e577c6ddb67e1a019e1fd4102ab0455c 100755
--- a/server/plugins-available/shelluser_base_plugin.inc.php
+++ b/server/plugins-available/shelluser_base_plugin.inc.php
@@ -88,6 +88,12 @@ class shelluser_base_plugin {
exec($command);
$app->log("Executed command: ".$command,LOGLEVEL_DEBUG);
$app->log("Added shelluser: ".$data['new']['username'],LOGLEVEL_DEBUG);
+
+ // call the ssh-rsa update function
+ $app->uses("getconf");
+ $this->data = $data;
+ $this->app = $app;
+ $this->_setup_ssh_rsa();
//* Create .bash_history file
touch(escapeshellcmd($data['new']['dir']).'/.bash_history');
@@ -134,7 +140,12 @@ class shelluser_base_plugin {
exec($command);
$app->log("Executed command: $command ",LOGLEVEL_DEBUG);
$app->log("Updated shelluser: ".$data['old']['username'],LOGLEVEL_DEBUG);
-
+
+ // call the ssh-rsa update function
+ $app->uses("getconf");
+ $this->data = $data;
+ $this->app = $app;
+ $this->_setup_ssh_rsa();
//* Create .bash_history file
if(!is_file($data['new']['dir']).'/.bash_history') {
@@ -183,7 +194,63 @@ class shelluser_base_plugin {
}
-
+ function _setup_ssh_rsa() {
+
+ // ssh-rsa authentication variables
+ $sshrsa = escapeshellcmd($this->data['new']['ssh_rsa']);
+ $usrdir = escapeshellcmd($this->data['new']['dir']);
+ $sshdir = escapeshellcmd($this->data['new']['dir']).'/.ssh';
+ $sshkeys= escapeshellcmd($this->data['new']['dir']).'/.ssh/authorized_keys';
+ global $app;
+
+ // determine the client id
+ $id = $this->data['new']['sys_groupid'];
+ if ($id>0) $id = $id -1;
+
+ $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE client_id = ".$id);
+ $userkey = $user['ssh_rsa'];
+ $username= $user['username'];
+
+ // If this user has no key yet, generate a pair
+ if ($userkey == '')
+ {
+ //Generate ssh-rsa-keys
+ exec('ssh-keygen -t rsa -C '.$username.'-rsa-key-'.time().' -f /tmp/id_rsa -N ""');
+
+ $privatekey = file_get_contents('/tmp/id_rsa');
+ $publickey = file_get_contents('/tmp/id_rsa.pub');
+
+ exec('rm -f /tmp/id_rsa /tmp/id_rsa.pub');
+
+ // Set the missing keypair
+ $app->db->query("UPDATE sys_user SET id_rsa='$privatekey' ,ssh_rsa='$publickey' WHERE client_id = ".$id);
+ $userkey = $publickey;
+
+ $this->app->log("ssh-rsa keypair generated for ".$username,LOGLEVEL_DEBUG);
+
+ };
+
+ if (!file_exists($sshkeys))
+ {
+ // add root's key
+ exec("mkdir '$sshdir'");
+ exec("cat /root/.ssh/authorized_keys > '$sshkeys'");
+ exec("echo '' >> '$sshkeys'");
+
+ // add the user's key
+ exec("echo '$userkey' >> '$sshkeys'");
+ exec("echo '' >> '$sshkeys'");
+ }
+ // add the custom key
+ exec("echo '$sshrsa' >> '$sshkeys'");
+ exec("echo '' >> '$sshkeys'");
+
+ // set proper file permissions
+ exec("chown -R ".escapeshellcmd($this->data['new']['puser']).":".escapeshellcmd($this->data['new']['pgroup'])." ".$usrdir);
+ exec("chmod 600 '$sshkeys'");
+
+ $this->app->log("ssh-rsa key added to ".$sshkeys,LOGLEVEL_DEBUG);
+ }
} // end class
diff --git a/server/plugins-available/shelluser_jailkit_plugin.inc.php b/server/plugins-available/shelluser_jailkit_plugin.inc.php
index b1ee45e2ff7806106b121b5982b37b775015cfb5..ca7b5abaf143d6aa5f5f4af9cbcf1e139196dbe7 100755
--- a/server/plugins-available/shelluser_jailkit_plugin.inc.php
+++ b/server/plugins-available/shelluser_jailkit_plugin.inc.php
@@ -272,6 +272,62 @@ class shelluser_jailkit_plugin {
chgrp(escapeshellcmd($this->data['new']['dir'].$jailkit_chroot_puserhome), $this->data['new']['pgroup']);
$this->app->log("Added created jailkit parent user home in : ".$this->data['new']['dir'].$jailkit_chroot_puserhome,LOGLEVEL_DEBUG);
+
+ // ssh-rsa authentication variables
+ $sshrsa = escapeshellcmd($this->data['new']['ssh_rsa']);
+ $usrdir = escapeshellcmd($this->data['new']['dir']).'/'.$jailkit_chroot_userhome;
+ $sshdir = escapeshellcmd($this->data['new']['dir']).'/'.$jailkit_chroot_userhome.'/.ssh';
+ $sshkeys= escapeshellcmd($this->data['new']['dir']).'/'.$jailkit_chroot_userhome.'/.ssh/authorized_keys';
+ global $app;
+
+ // determine the client id
+ $id = $this->data['new']['sys_groupid'];
+ if ($id>0) $id = $id -1;
+
+ $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE client_id = ".$id);
+ $userkey = $user['ssh_rsa'];
+ $username= $user['username'];
+
+ // If this user has no key yet, generate a pair
+ if ($userkey == '')
+ {
+ //Generate ssh-rsa-keys
+ exec('ssh-keygen -t rsa -C '.$username.'-rsa-key-'.time().' -f /tmp/id_rsa -N ""');
+
+ $privatekey = file_get_contents('/tmp/id_rsa');
+ $publickey = file_get_contents('/tmp/id_rsa.pub');
+
+ exec('rm -f /tmp/id_rsa /tmp/id_rsa.pub');
+
+ // Set the missing keypair
+ $app->db->query("UPDATE sys_user SET id_rsa='$privatekey' ,ssh_rsa='$publickey' WHERE client_id = ".$id);
+ $userkey = $publickey;
+
+ $this->app->log("ssh-rsa keypair generated for ".$username,LOGLEVEL_DEBUG);
+
+ };
+
+ if (!file_exists($sshkeys))
+ {
+ // add root's key
+ exec("mkdir '$sshdir'");
+ exec("cat /root/.ssh/authorized_keys > '$sshkeys'");
+ exec("echo '' >> '$sshkeys'");
+
+ // add the user's key
+ exec("echo '$userkey' >> '$sshkeys'");
+ exec("echo '' >> '$sshkeys'");
+ }
+ // add the custom key
+ exec("echo '$sshrsa' >> '$sshkeys'");
+ exec("echo '' >> '$sshkeys'");
+
+ // set proper file permissions
+ exec("chown -R ".escapeshellcmd($this->data['new']['puser']).":".escapeshellcmd($this->data['new']['pgroup'])." ".$usrdir);
+ exec("chmod 600 '$sshkeys'");
+
+ $this->app->log("ssh-rsa key added to ".$sshkeys,LOGLEVEL_DEBUG);
+
}
//* Update the website root directory permissions depending on the security level