Skip to content

Commit 5e10642

Browse files
author
Kristan Kenney
committed
Add SSH to list of services
1 parent 9e46d46 commit 5e10642

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

bin/v-list-sys-services

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,13 @@ if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'remote' ]; then
263263
data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'"
264264
fi
265265

266+
# Checking SSH daemon
267+
if [ -e "/etc/ssh/sshd_config" ]; then
268+
get_srv_state ssh
269+
data="$data\nNAME='ssh' SYSTEM='SSH Access' STATE='$state'"
270+
data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'"
271+
fi
272+
266273
# Checking FIREWALL system
267274
if [ ! -z "$FIREWALL_SYSTEM" ] && [ "$FIREWALL_SYSTEM" != 'remote' ]; then
268275
state="stopped"
@@ -274,6 +281,7 @@ if [ ! -z "$FIREWALL_SYSTEM" ] && [ "$FIREWALL_SYSTEM" != 'remote' ]; then
274281
data="$data STATE='$state' CPU='0' MEM='0' RTIME='$rtime'"
275282
fi
276283

284+
277285
# Checking FIREWALL Fail2ban extention
278286
if [ ! -z "$FIREWALL_EXTENSION" ]; then
279287
get_srv_state $FIREWALL_EXTENSION fail2ban-server script

bin/v-open-fs-config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fi
2828
if [ ! -z "$src_file" ]; then
2929
rpath=$(readlink -f "$src_file")
3030
services="nginx|apache|httpd|php|ftp|bind|named|exim|dovecot|spamassassin"
31-
services="$services|clam|mysql|postgresql|pgsql|cron|fail2ban|iptables"
31+
services="$services|clam|mysql|postgresql|pgsql|cron|ssh|fail2ban|iptables"
3232
services="$services|my.cnf"
3333
spath=$(echo "$rpath" |egrep "$services")
3434
if [ -z "$spath" ]; then

web/edit/server/ssh/index.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
error_reporting(NULL);
3+
$TAB = 'SERVER';
4+
5+
// Main include
6+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
7+
8+
// Check user
9+
if ($_SESSION['user'] != 'admin') {
10+
header("Location: /list/user");
11+
exit;
12+
}
13+
14+
// Check POST request
15+
if (!empty($_POST['save'])) {
16+
17+
// Check token
18+
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
19+
header('location: /login/');
20+
exit();
21+
}
22+
23+
// Set restart flag
24+
$v_restart = 'yes';
25+
if (empty($_POST['v_restart'])) $v_restart = 'no';
26+
27+
// Update config
28+
if (!empty($_POST['v_config'])) {
29+
exec ('mktemp', $mktemp_output, $return_var);
30+
$new_conf = $mktemp_output[0];
31+
$fp = fopen($new_conf, 'w');
32+
fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
33+
fclose($fp);
34+
exec (HESTIA_CMD."v-change-sys-service-config ".$new_conf." ssh ".$v_restart, $output, $return_var);
35+
check_return_code($return_var,$output);
36+
unset($output);
37+
unlink($new_conf);
38+
}
39+
40+
// Set success message
41+
if (empty($_SESSION['error_msg'])) {
42+
$_SESSION['ok_msg'] = __('Changes has been saved.');
43+
}
44+
45+
}
46+
47+
$v_config_path = '/etc/ssh/sshd_config';
48+
$v_service_name = strtoupper('ssh');
49+
50+
// Read config
51+
$v_config = shell_exec(HESTIA_CMD."v-open-fs-config ".$v_config_path);
52+
53+
// Render page
54+
render_page($user, $TAB, 'edit_server_service');
55+
56+
// Flush session messages
57+
unset($_SESSION['error_msg']);
58+
unset($_SESSION['ok_msg']);

0 commit comments

Comments
 (0)