]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/remote.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 #use CGI::Carp 'fatalsToBrowser';
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
32 my %remotesettings=();
37 &Header
::showhttpheaders
();
39 $remotesettings{'ENABLE_SSH'} = 'off';
40 $remotesettings{'ENABLE_SSH_PROTOCOL1'} = 'off';
41 $remotesettings{'ENABLE_SSH_PORTFW'} = 'off';
42 $remotesettings{'ACTION'} = '';
43 &Header
::getcgihash
(\
%remotesettings);
45 if ( (($remotesettings{'ACTION'} eq $Lang::tr
{'save'}) || ($remotesettings{'ACTION'} eq $Lang::tr
{'ssh tempstart15'}) || ($remotesettings{'ACTION'} eq $Lang::tr
{'ssh tempstart30'})) && $remotesettings{'ACTION'} ne "" )
47 # not existing here indicates the box is unticked
48 $remotesettings{'ENABLE_SSH_PASSWORDS'} = 'off' unless exists $remotesettings{'ENABLE_SSH_PASSWORDS'};
49 $remotesettings{'ENABLE_SSH_KEYS'} = 'off' unless exists $remotesettings{'ENABLE_SSH_KEYS'};
52 &General
::writehash
("${General::swroot}/remote/settings", \
%remotesettings);
53 if ($remotesettings{'ENABLE_SSH'} eq 'on')
55 &General
::log($Lang::tr
{'ssh is enabled'});
56 if ($remotesettings{'ENABLE_SSH_PASSWORDS'} eq 'off'
57 and $remotesettings{'ENABLE_SSH_KEYS'} eq 'off')
59 $errormessage = $Lang::tr
{'ssh no auth'};
61 system ('/usr/bin/touch', "${General::swroot}/remote/enablessh");
65 &General
::log($Lang::tr
{'ssh is disabled'});
66 unlink "${General::swroot}/remote/enablessh";
69 if ($remotesettings{'ENABLE_SSH_PROTOCOL1'} eq 'on')
71 &General
::log($Lang::tr
{'ssh1 enabled'});
75 &General
::log($Lang::tr
{'ssh1 disabled'});
77 if ( $remotesettings{'ACTION'} eq $Lang::tr
{'ssh tempstart15'} || $remotesettings{'ACTION'} eq $Lang::tr
{'ssh tempstart30'} ){
78 if ($remotesettings{'ENABLE_SSH'} eq 'off')
80 system ('/usr/bin/touch', "${General::swroot}/remote/enablessh");
81 system('/usr/local/bin/sshctrl');
83 if ( $remotesettings{'ACTION'} eq $Lang::tr
{'ssh tempstart15'} ) { $counter = 900;}
84 elsif ( $remotesettings{'ACTION'} eq $Lang::tr
{'ssh tempstart30'} ) { $counter = 1800;}
86 system("/usr/local/bin/sshctrl tempstart $counter >/dev/null");
89 system('/usr/local/bin/sshctrl') == 0
90 or $errormessage = "$Lang::tr{'bad return code'} " . $?
/256;
94 &General
::readhash
("${General::swroot}/remote/settings", \
%remotesettings);
96 # not existing here means they're undefined and the default value should be
98 $remotesettings{'ENABLE_SSH_PASSWORDS'} = 'on' unless exists $remotesettings{'ENABLE_SSH_PASSWORDS'};
99 $remotesettings{'ENABLE_SSH_KEYS'} = 'on' unless exists $remotesettings{'ENABLE_SSH_KEYS'};
101 $checked{'ENABLE_SSH'}{'off'} = '';
102 $checked{'ENABLE_SSH'}{'on'} = '';
103 $checked{'ENABLE_SSH'}{$remotesettings{'ENABLE_SSH'}} = "checked='checked'";
104 $checked{'ENABLE_SSH_PROTOCOL1'}{'off'} = '';
105 $checked{'ENABLE_SSH_PROTOCOL1'}{'on'} = '';
106 $checked{'ENABLE_SSH_PROTOCOL1'}{$remotesettings{'ENABLE_SSH_PROTOCOL1'}} = "checked='checked'";
107 $checked{'ENABLE_SSH_PORTFW'}{'off'} = '';
108 $checked{'ENABLE_SSH_PORTFW'}{'on'} = '';
109 $checked{'ENABLE_SSH_PORTFW'}{$remotesettings{'ENABLE_SSH_PORTFW'}} = "checked='checked'";
110 $checked{'ENABLE_SSH_PASSWORDS'}{'off'} = '';
111 $checked{'ENABLE_SSH_PASSWORDS'}{'on'} = '';
112 $checked{'ENABLE_SSH_PASSWORDS'}{$remotesettings{'ENABLE_SSH_PASSWORDS'}} = "checked='checked'";
113 $checked{'ENABLE_SSH_KEYS'}{'off'} = '';
114 $checked{'ENABLE_SSH_KEYS'}{'on'} = '';
115 $checked{'ENABLE_SSH_KEYS'}{$remotesettings{'ENABLE_SSH_KEYS'}} = "checked='checked'";
118 &Header
::openpage
($Lang::tr
{'remote access'}, 1, '');
120 &Header
::openbigbox
('100%', 'left', '', $errormessage);
123 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
124 print "<FONT CLASS='base'>$errormessage </FONT>\n";
128 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
130 &Header
::openbox
('100%', 'left', 'SSH:');
134 <td><input type='checkbox' name='ENABLE_SSH' $checked{'ENABLE_SSH'}{'on'} /></td>
135 <td class='base' colspan='2'>$Lang::tr{'ssh access'}</td>
139 <td><input type='checkbox' name='ENABLE_SSH_PROTOCOL1' $checked{'ENABLE_SSH_PROTOCOL1'}{'on'} /></td>
140 <td width='100%' class='base'>$Lang::tr{'ssh1 support'}</td>
144 <td><input type='checkbox' name='ENABLE_SSH_PORTFW' $checked{'ENABLE_SSH_PORTFW'}{'on'} /></td>
145 <td width='100%' class='base'>$Lang::tr{'ssh portfw'}</td>
149 <td><input type='checkbox' name='ENABLE_SSH_PASSWORDS' $checked{'ENABLE_SSH_PASSWORDS'}{'on'} /></td>
150 <td width='100%' class='base'>$Lang::tr{'ssh passwords'}</td>
154 <td><input type='checkbox' name='ENABLE_SSH_KEYS' $checked{'ENABLE_SSH_KEYS'}{'on'} /></td>
155 <td width='100%' class='base'>$Lang::tr{'ssh keys'}</td>
158 <td align='center' colspan='3'><hr />
159 <input type='submit' name='ACTION' value='$Lang::tr{'ssh tempstart15'}' />
160 <input type='submit' name='ACTION' value='$Lang::tr{'ssh tempstart30'}' />
161 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
170 &Header
::openbox
('100%', 'left', $Lang::tr
{'ssh host keys'});
175 <tr><td class='boldbase'><b>$Lang::tr{'ssh key'}</b></td>
176 <td class='boldbase'><b>$Lang::tr{'ssh fingerprint'}</b></td>
177 <td class='boldbase'><b>$Lang::tr{'ssh key size'}</b></td></tr>
181 &viewkey
("/etc/ssh/ssh_host_key.pub","RSA1");
182 &viewkey
("/etc/ssh/ssh_host_rsa_key.pub","RSA2");
183 &viewkey
("/etc/ssh/ssh_host_dsa_key.pub","DSA");
189 &Header
::closebigbox
();
191 &Header
::closepage
();
201 my @temp = split(/ /,`/usr/bin/ssh-keygen -l -f $key`);
202 my $keysize = &Header
::cleanhtml
($temp[0],"y");
203 my $fingerprint = &Header
::cleanhtml
($temp[1],"y");
204 print "<tr><td>$key ($name)</td><td><code>$fingerprint</code></td><td align='center'>$keysize</td></tr>\n";