1
|
#! /usr/local/bin/php -f
|
2
|
<?php
|
3
|
/*
|
4
|
sshd - Modified to work on disk based system
|
5
|
Copyright 2004 Scott K Ullrich
|
6
|
|
7
|
Original Copyright (C) 2004 Fred Mol <fredmol@xs4all.nl>.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
require_once("config.inc");
|
32
|
|
33
|
$stderr = fopen("php://stderr", "w");
|
34
|
fwrite($stderr, "Initializing module ssh...\n");
|
35
|
|
36
|
if (!is_dir("/var/empty")) {
|
37
|
// Home directory of sshd.
|
38
|
mkdir("/var/empty", 0555);
|
39
|
}
|
40
|
|
41
|
if(!file_exists("")) {
|
42
|
// Login related files.
|
43
|
touch("/var/log/lastlog");
|
44
|
}
|
45
|
|
46
|
// Make the root password the same as the admin password of m0n0.
|
47
|
$fd = popen("/usr/sbin/pw usermod -n root -H 0", "w");
|
48
|
fwrite($fd, $config['system']['password']);
|
49
|
pclose($fd);
|
50
|
|
51
|
$sshConfigDir = "/etc/ssh";
|
52
|
if (!file_exists("$sshConfigDir/ssh_host_key")) {
|
53
|
system("/usr/bin/ssh-keygen -t rsa1 -N '' -f $sshConfigDir/ssh_host_key");
|
54
|
system("/usr/bin/ssh-keygen -t rsa -N '' -f $sshConfigDir/ssh_host_rsa_key");
|
55
|
system("/usr/bin/ssh-keygen -t dsa -N '' -f $sshConfigDir/ssh_host_dsa_key");
|
56
|
}
|
57
|
|
58
|
// And finally ...
|
59
|
system("sshd");
|
60
|
fwrite($stderr, "Done.\n");
|
61
|
?>
|
62
|
|