Commit 948b5bcc authored by Franco Fichtner's avatar Franco Fichtner

system: flip ssh settings for clarity

parent e2a82d38
...@@ -202,9 +202,6 @@ ...@@ -202,9 +202,6 @@
<interval>monthly</interval> <interval>monthly</interval>
</bogons> </bogons>
<kill_states/> <kill_states/>
<ssh>
<sshdkeyonly/>
</ssh>
</system> </system>
<interfaces> <interfaces>
<wan> <wan>
......
...@@ -145,7 +145,7 @@ EOD; ...@@ -145,7 +145,7 @@ EOD;
return; return;
} while (!isset($wanif)); } while (!isset($wanif));
$config['system']['enablesshd'] = 'enabled'; $config['system']['ssh']['enabled'] = 'enabled';
$key = 'y'; $key = 'y';
} else { //Manually assign interfaces } else { //Manually assign interfaces
......
...@@ -3562,8 +3562,9 @@ function filter_get_antilockout_ports($wantarray = false) { ...@@ -3562,8 +3562,9 @@ function filter_get_antilockout_ports($wantarray = false) {
if (($config['system']['webgui']['protocol'] == "https") && !isset($config['system']['webgui']['disablehttpredirect']) && ($guiport != "80")) if (($config['system']['webgui']['protocol'] == "https") && !isset($config['system']['webgui']['disablehttpredirect']) && ($guiport != "80"))
$lockoutports[] = "80"; $lockoutports[] = "80";
if (isset($config['system']['enablesshd'])) if (isset($config['system']['ssh']['enabled'])) {
$lockoutports[] = empty($config['system']['ssh']['port']) ? "22" : $config['system']['ssh']['port']; $lockoutports[] = empty($config['system']['ssh']['port']) ? "22" : $config['system']['ssh']['port'];
}
if ($wantarray) if ($wantarray)
return $lockoutports; return $lockoutports;
......
...@@ -48,7 +48,7 @@ $g = array( ...@@ -48,7 +48,7 @@ $g = array(
"product_copyright_owner" => "Deciso B.V.", "product_copyright_owner" => "Deciso B.V.",
"product_copyright_years" => "2014 - 2015", "product_copyright_years" => "2014 - 2015",
"product_copyright_url" => "https://www.deciso.com/", "product_copyright_url" => "https://www.deciso.com/",
"latest_config" => "11.1", "latest_config" => "11.2",
"wireless_regex" => "/^(ndis|wi|ath|an|ral|ural|iwi|wlan|rum|run|bwn|zyd|mwl|bwi|ipw|iwn|malo|uath|upgt|urtw|wpi)/", "wireless_regex" => "/^(ndis|wi|ath|an|ral|ural|iwi|wlan|rum|run|bwn|zyd|mwl|bwi|ipw|iwn|malo|uath|upgt|urtw|wpi)/",
); );
......
...@@ -147,10 +147,10 @@ if (!function_exists('get_services')) { ...@@ -147,10 +147,10 @@ if (!function_exists('get_services')) {
$services[] = $pconfig; $services[] = $pconfig;
} }
if (isset($config['system']['enablesshd'])) { if (isset($config['system']['ssh']['enabled'])) {
$pconfig = array(); $pconfig = array();
$pconfig['name'] = "sshd"; $pconfig['name'] = 'sshd';
$pconfig['description'] = gettext("Secure Shell Daemon"); $pconfig['description'] = gettext('Secure Shell Daemon');
$services[] = $pconfig; $services[] = $pconfig;
} }
......
...@@ -3245,12 +3245,10 @@ function upgrade_109_to_110() { ...@@ -3245,12 +3245,10 @@ function upgrade_109_to_110() {
} }
} }
function upgrade_110_to_111() { function upgrade_110_to_111()
{
global $config; global $config;
/* OPNsense modifications on top of this version */
$config['theme'] = 'opnsense';
/* Make sure unbound user exist */ /* Make sure unbound user exist */
mwexec('/usr/sbin/pw groupadd -n unbound -g 59', true); mwexec('/usr/sbin/pw groupadd -n unbound -g 59', true);
mwexec('/usr/sbin/pw useradd -n unbound -c "Unbound DNS Resolver" -d /var/unbound -s /usr/sbin/nologin -u 59 -g 59', true); mwexec('/usr/sbin/pw useradd -n unbound -c "Unbound DNS Resolver" -d /var/unbound -s /usr/sbin/nologin -u 59 -g 59', true);
...@@ -3372,3 +3370,21 @@ function upgrade_110_to_111() { ...@@ -3372,3 +3370,21 @@ function upgrade_110_to_111() {
unset($pkg, $new); unset($pkg, $new);
} }
function upgrade_111_to_112()
{
global $config;
$config['theme'] = 'opnsense';
if (isset($config['system']['ssh']['sshdkeyonly'])) {
unset($config['system']['ssh']['sshdkeyonly']);
} else {
$config['system']['ssh']['passwordauth'] = true;
}
if (isset($config['system']['sshdenable'])) {
$config['system']['ssh']['enabled'] = true;
unset($config['system']['sshdenable']);
}
}
...@@ -36,7 +36,7 @@ require_once('shaper.inc'); ...@@ -36,7 +36,7 @@ require_once('shaper.inc');
killbyname('sshd'); killbyname('sshd');
if (!isset($config['system']['enablesshd'])) { if (!isset($config['system']['ssh']['enabled'])) {
return; return;
} }
...@@ -103,12 +103,12 @@ $sshconf .= "Subsystem\tsftp\tinternal-sftp\n"; ...@@ -103,12 +103,12 @@ $sshconf .= "Subsystem\tsftp\tinternal-sftp\n";
if (isset($config['system']['ssh']['permitrootlogin'])) { if (isset($config['system']['ssh']['permitrootlogin'])) {
$sshconf .= "PermitRootLogin yes\n"; $sshconf .= "PermitRootLogin yes\n";
} }
if (isset($config['system']['ssh']['sshdkeyonly'])) { if (isset($config['system']['ssh']['passwordauth'])) {
$sshconf .= "PasswordAuthentication no\n";
$sshconf .= "ChallengeResponseAuthentication no\n";
} else {
$sshconf .= "PasswordAuthentication yes\n";
$sshconf .= "ChallengeResponseAuthentication yes\n"; $sshconf .= "ChallengeResponseAuthentication yes\n";
$sshconf .= "PasswordAuthentication yes\n";
} else {
$sshconf .= "ChallengeResponseAuthentication no\n";
$sshconf .= "PasswordAuthentication no\n";
} }
/* Write the new sshd config file */ /* Write the new sshd config file */
......
...@@ -49,9 +49,9 @@ $pconfig['althostnames'] = $config['system']['webgui']['althostnames']; ...@@ -49,9 +49,9 @@ $pconfig['althostnames'] = $config['system']['webgui']['althostnames'];
$pconfig['enableserial'] = $config['system']['enableserial']; $pconfig['enableserial'] = $config['system']['enableserial'];
$pconfig['serialspeed'] = $config['system']['serialspeed']; $pconfig['serialspeed'] = $config['system']['serialspeed'];
$pconfig['primaryconsole'] = $config['system']['primaryconsole']; $pconfig['primaryconsole'] = $config['system']['primaryconsole'];
$pconfig['enablesshd'] = $config['system']['enablesshd']; $pconfig['enablesshd'] = $config['system']['ssh']['enabled'];
$pconfig['sshport'] = $config['system']['ssh']['port']; $pconfig['sshport'] = $config['system']['ssh']['port'];
$pconfig['sshdkeyonly'] = isset($config['system']['ssh']['sshdkeyonly']); $pconfig['passwordauth'] = isset($config['system']['ssh']['passwordauth']);
$pconfig['sshdpermitrootlogin'] = isset($config['system']['ssh']['permitrootlogin']); $pconfig['sshdpermitrootlogin'] = isset($config['system']['ssh']['permitrootlogin']);
$pconfig['quietlogin'] = isset($config['system']['webgui']['quietlogin']); $pconfig['quietlogin'] = isset($config['system']['webgui']['quietlogin']);
...@@ -89,10 +89,11 @@ if ($_POST) { ...@@ -89,10 +89,11 @@ if ($_POST) {
if(!is_port($_POST['sshport'])) if(!is_port($_POST['sshport']))
$input_errors[] = gettext("You must specify a valid port number"); $input_errors[] = gettext("You must specify a valid port number");
if($_POST['sshdkeyonly'] == "yes") if ($_POST['passwordauth'] == 'yes') {
$config['system']['ssh']['sshdkeyonly'] = "enabled"; $config['system']['ssh']['passwordauth'] = 'enabled';
else if (isset($config['system']['ssh']['sshdkeyonly'])) } elseif (isset($config['system']['ssh']['passwordauth'])) {
unset($config['system']['ssh']['sshdkeyonly']); unset($config['system']['ssh']['passwordauth']);
}
if($_POST['sshdpermitrootlogin'] == "yes") if($_POST['sshdpermitrootlogin'] == "yes")
$config['system']['ssh']['permitrootlogin'] = "enabled"; $config['system']['ssh']['permitrootlogin'] = "enabled";
...@@ -176,17 +177,19 @@ if ($_POST) { ...@@ -176,17 +177,19 @@ if ($_POST) {
else else
unset($config['system']['webgui']['althostnames']); unset($config['system']['webgui']['althostnames']);
$sshd_enabled = $config['system']['enablesshd']; $sshd_enabled = $config['system']['ssh']['enabled'];
if($_POST['enablesshd']) if ($_POST['enablesshd']) {
$config['system']['enablesshd'] = "enabled"; $config['system']['ssh']['enabled'] = 'enabled';
else } else {
unset($config['system']['enablesshd']); unset($config['system']['ssh']['enabled']);
}
$sshd_keyonly = isset($config['system']['ssh']['sshdkeyonly']); $sshd_passwordauth = isset($config['system']['ssh']['passwordauth']);
if ($_POST['sshdkeyonly']) if ($_POST['passwordauth']) {
$config['system']['ssh']['sshdkeyonly'] = true; $config['system']['ssh']['passwordauth'] = true;
else if (isset($config['system']['ssh']['sshdkeyonly'])) } else if (isset($config['system']['ssh']['passwordauth'])) {
unset($config['system']['ssh']['sshdkeyonly']); unset($config['system']['ssh']['passwordauth']);
}
$sshd_port = $config['system']['ssh']['port']; $sshd_port = $config['system']['ssh']['port'];
if ($_POST['sshport']) if ($_POST['sshport'])
...@@ -197,8 +200,8 @@ if ($_POST) { ...@@ -197,8 +200,8 @@ if ($_POST) {
if (!isset($_POST['sshdpermitrootlogin']) && isset($config['system']['ssh']['permitrootlogin'])) if (!isset($_POST['sshdpermitrootlogin']) && isset($config['system']['ssh']['permitrootlogin']))
unset($config['system']['ssh']['permitrootlogin']); unset($config['system']['ssh']['permitrootlogin']);
if (($sshd_enabled != $config['system']['enablesshd']) || if (($sshd_enabled != $config['system']['ssh']['enabled']) ||
($sshd_keyonly != $config['system']['ssh']['sshdkeyonly']) || ($sshd_passwordauth != $config['system']['ssh']['passwordauth']) ||
($sshd_port != $config['system']['ssh']['port']) || ($sshd_port != $config['system']['ssh']['port']) ||
($pconfig['system']['ssh']['permitrootlogin'] != isset($config['system']['ssh']['permitrootlogin'])) ) { ($pconfig['system']['ssh']['permitrootlogin'] != isset($config['system']['ssh']['permitrootlogin'])) ) {
$restart_sshd = true; $restart_sshd = true;
...@@ -501,10 +504,10 @@ include("head.inc"); ...@@ -501,10 +504,10 @@ include("head.inc");
<tr> <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Authentication Method"); ?></td> <td width="22%" valign="top" class="vncell"><?=gettext("Authentication Method"); ?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<input name="sshdkeyonly" type="checkbox" id="sshdkeyonly" value="yes" <?php if ($pconfig['sshdkeyonly']) echo "checked=\"checked\""; ?> /> <input name="passwordauth" type="checkbox" id="passwordauth" value="yes" <?php if ($pconfig['passwordauth']) echo "checked=\"checked\""; ?> />
<strong><?=gettext("Disable password login for Secure Shell (RSA/DSA key only)"); ?></strong> <strong><?=gettext("Enable password login for Secure Shell"); ?></strong>
<br /> <br />
<?=gettext("When enabled, authorized keys need to be configured for each"); ?> <?=gettext("When disabled, authorized keys need to be configured for each"); ?>
<a href="system_usermanager.php"><?=gettext("user"); ?></a> <a href="system_usermanager.php"><?=gettext("user"); ?></a>
<?=gettext("that has been granted secure shell access."); ?> <?=gettext("that has been granted secure shell access."); ?>
</td> </td>
...@@ -603,7 +606,7 @@ if ($restart_sshd) { ...@@ -603,7 +606,7 @@ if ($restart_sshd) {
killbyname("sshd"); killbyname("sshd");
log_error(gettext("secure shell configuration has changed. Stopping sshd.")); log_error(gettext("secure shell configuration has changed. Stopping sshd."));
if ($config['system']['enablesshd']) { if ($config['system']['ssh']['enabled']) {
log_error(gettext("secure shell configuration has changed. Restarting sshd.")); log_error(gettext("secure shell configuration has changed. Restarting sshd."));
send_event("service restart sshd"); send_event("service restart sshd");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment