OPNsense Forum

Archive => 19.1 Legacy Series => Topic started by: LouieLouie on May 19, 2019, 07:54:42 PM

Title: [SOLVED] How to start/stop/restart sshd with Monit in GUI
Post by: LouieLouie on May 19, 2019, 07:54:42 PM
Running opnsense 19.1.8, I am trying to add sshd to Monit service monitoring. In the gui, the start and stop commands are required with the full path to the command. I've searched freebsd forums and tutorials, the /etc/rc.d commands don't work (can't even find rc.config), the 'service sshd start' commands aren't accepted.

May I ask for help, please? Thanks in advance!
Title: Re: How to start/stop/restart sshd with Monit in GUI
Post by: hbc on May 20, 2019, 09:01:47 AM
Try:

# /usr/local/sbin/configctl sshd restart

More about configctl:
https://docs.opnsense.org/development/backend/configd.html (https://docs.opnsense.org/development/backend/configd.html)
Title: Re: How to start/stop/restart sshd with Monit in GUI
Post by: LouieLouie on May 20, 2019, 01:10:11 PM
hbc:  Thank you!

This # /usr/local/sbin/configctl sshd restart didn't work because the default configd script is named openssh instead of sshd.  But, by changing 'sshd' to 'openssh' , it worked.

I've never heard of configctl, that helped immensely.  Thanks for you time!
Title: Re: [SOLVED] How to start/stop/restart sshd with Monit in GUI
Post by: franco on May 20, 2019, 09:08:27 PM
Hi,

I built something for you:

# pluginctl -s
configd
dhcpd
dhcpd6
dnsmasq
dpinger
dyndns
flowd_aggregate
ipfw
login
ntpd
openssh
pf
radvd
samplicate
strongswan
syslog
unbound
# pluginctl -s openssh stop
Connection to 10.0.0.1 closed by remote host.
Connection to 10.0.0.1 closed.

It hooks into the service control functionality (start, stop, restart) that you can see on the GUI. It's a patch that will likely be in 19.1.9.

https://github.com/opnsense/core/commit/255e9b76

You can try it on 19.1.8 using this command:

# opnsense-patch 255e9b76


Cheers,
Franco
Title: Re: [SOLVED] How to start/stop/restart sshd with Monit in GUI
Post by: LouieLouie on May 21, 2019, 11:09:19 PM
Franco, got a 'hunks failed' message when I attempted the patch:

sudo opnsense-patch 255e9b76
Password:
Fetched 255e9b76 via https://github.com/opnsense/core
1 out of 1 hunks failed while patching sbin/pluginctl

OPNsense 19.1.8-amd64
FreeBSD 11.2-RELEASE-p10-HBSD
LibreSSL 2.8.3
Title: Re: [SOLVED] How to start/stop/restart sshd with Monit in GUI
Post by: franco on May 22, 2019, 02:39:00 PM
Oh, doesn't patch cleanly because of require header stuff....maybe fetch the raw file instead:

# cd /usr/local/sbin
# fetch https://raw.githubusercontent.com/opnsense/core/master/src/sbin/pluginctl
# chmod 755 pluginctl


Cheers,
Franco
Title: Re: [SOLVED] How to start/stop/restart sshd with Monit in GUI
Post by: LouieLouie on May 23, 2019, 02:21:42 PM
That worked.  I cat'd pluginctl, hoping that I understand correctly  ??? .  Testing today.  Thanks!
Title: Re: [SOLVED] How to start/stop/restart sshd with Monit in GUI
Post by: LouieLouie on May 23, 2019, 06:51:07 PM
Franco,

May I ask if you could explain the use of 'pluginctl -c' or '-s' (configure mode vs service mode)?

Aside from that I tried it at the command line using -s and it worked.  Adding it to the monit config for unbound and openssh now.
Title: Re: [SOLVED] How to start/stop/restart sshd with Monit in GUI
Post by: franco on May 23, 2019, 07:15:26 PM
Hi LouieLouie,

So configure mode (-c) is calling internal functions to reload the configuration and (all of its) services. Service mode (-s) simply starts stops or restarts a particular service without reconfiguring it.

-c without an argument gives you all possible reconfiguration "points" like bootup, local, remote, vpn where services can be clustered. These calls are all over the code to provide hooks to plugins.

-s without an argument gives you all configured services on the box for starting or stopping them manually (like you would in the GUI under System: Services).


Cheers,
Franco
Title: Re: [SOLVED] How to start/stop/restart sshd with Monit in GUI
Post by: lox on July 19, 2019, 01:22:13 AM
I am trying to setup monit for unbound because it fails to start on boot (https://forum.opnsense.org/index.php?topic=13338.msg61301#msg61301)

root@router:~ # pluginctl -s
root@router:~ #


It doesn't return anything and pluginctl -s unbound start/stop/restart has no effect