Commit d4ecff6f authored by Franco Fichtner's avatar Franco Fichtner

rc: add sshd for installer (2/2); closes #1072

parent bde361f7
...@@ -211,9 +211,7 @@ interfaces_loopback_configure(); ...@@ -211,9 +211,7 @@ interfaces_loopback_configure();
/* start syslogd */ /* start syslogd */
system_syslogd_start(); system_syslogd_start();
echo "Starting Secure Shell Services...";
mwexec("/usr/local/etc/rc.sshd"); mwexec("/usr/local/etc/rc.sshd");
echo "done.\n";
/* set up interfaces */ /* set up interfaces */
mute_kernel_msgs(); mute_kernel_msgs();
...@@ -370,5 +368,7 @@ if ($setup_installer) { ...@@ -370,5 +368,7 @@ if ($setup_installer) {
$root['shell'] = '/usr/local/etc/rc.installer'; $root['shell'] = '/usr/local/etc/rc.installer';
$root['name'] = 'installer'; $root['name'] = 'installer';
local_user_set($root); local_user_set($root);
mwexec("/usr/local/etc/rc.sshd installer");
} }
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
/* /*
Copyright (C) 2004 Scott K Ullrich Copyright (C) 2004 Scott K Ullrich
Copyright (C) 2004 Fred Mol <fredmol@xs4all.nl>. Copyright (C) 2004 Fred Mol <fredmol@xs4all.nl>.
Copyright (C) 2015 Franco Fichtner <franco@opnsense.org> Copyright (C) 2015-2016 Franco Fichtner <franco@opnsense.org>
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -39,7 +39,18 @@ $etc_ssh = '/usr/local/etc/ssh'; ...@@ -39,7 +39,18 @@ $etc_ssh = '/usr/local/etc/ssh';
/* if run from a shell session, `-af' and the full path is needed */ /* if run from a shell session, `-af' and the full path is needed */
mwexecf('/bin/pkill -af %s', $sbin_sshd); mwexecf('/bin/pkill -af %s', $sbin_sshd);
if (!isset($config['system']['ssh']['enabled'])) { $sshcfg = null;
if (isset($config['system']['ssh'])) {
if (isset($config['system']['ssh']['enabled'])) {
$sshcfg = $config['system']['ssh'];
}
} elseif (count($argv) > 1 && $argv[1] == 'installer') {
/* only revert to installer config when ssh is not set at all */
$sshcfg = array( 'permitrootlogin' => 1, 'passwordauth' => 1);
}
if ($sshcfg === null) {
return; return;
} }
...@@ -73,21 +84,8 @@ foreach($keys as $name) { ...@@ -73,21 +84,8 @@ foreach($keys as $name) {
/* Login related files. */ /* Login related files. */
touch("/var/log/lastlog"); touch("/var/log/lastlog");
if (isset($config['system']['ssh']['port'])) { $sshport = isset($sshcfg['port']) ? $sshcfg['port'] : 22;
$sshport = $config['system']['ssh']['port'];
} else {
$sshport = 22;
}
/*
* XXX ZOMG sshd_config BOOTSTRAPPING ACTION
*
* We can't just ditch the system file by default and roll
* our own. Instead, use the current file to find the actual
* settings that need toggling, then toggle them!
*/
/* Include default configuration for OPNsense */
$sshconf = "# This file was automatically generated by /usr/local/etc/rc.sshd\n"; $sshconf = "# This file was automatically generated by /usr/local/etc/rc.sshd\n";
$sshconf .= "Port {$sshport}\n"; $sshconf .= "Port {$sshport}\n";
$sshconf .= "Protocol 2\n"; $sshconf .= "Protocol 2\n";
...@@ -98,10 +96,10 @@ $sshconf .= "UseDNS no\n"; ...@@ -98,10 +96,10 @@ $sshconf .= "UseDNS no\n";
$sshconf .= "X11Forwarding no\n"; $sshconf .= "X11Forwarding no\n";
$sshconf .= "PubkeyAuthentication yes\n"; $sshconf .= "PubkeyAuthentication yes\n";
$sshconf .= "Subsystem\tsftp\tinternal-sftp\n"; $sshconf .= "Subsystem\tsftp\tinternal-sftp\n";
if (isset($config['system']['ssh']['permitrootlogin'])) { if (isset($sshcfg['permitrootlogin'])) {
$sshconf .= "PermitRootLogin yes\n"; $sshconf .= "PermitRootLogin yes\n";
} }
if (isset($config['system']['ssh']['passwordauth'])) { if (isset($sshcfg['passwordauth'])) {
$sshconf .= "ChallengeResponseAuthentication yes\n"; $sshconf .= "ChallengeResponseAuthentication yes\n";
$sshconf .= "PasswordAuthentication yes\n"; $sshconf .= "PasswordAuthentication yes\n";
} else { } else {
......
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