View this page as Markdown | Gemtext
,_---~~~~~----._ _,,_,*^____ _____``*g*\"*, / __/ /' ^. / \ ^@q f @f | | | | 0 _/ \`/ \~__((@/ __ \__((@/ \ | _l__l_ I <--- The Go Gopher } [______] I ] | | | | ] ~ ~ | | | | | | | A ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~,--,-/ \---,-/|~~,~~~~~~~~~~~~~~~~~~~~~~~~~~~ _|\,'. /| /| `/|-. \`.' /| , `;. ,'\ A A A A _ /| `.; ,/ _ A _ / _ /| ; /\ / \ , , A / / `/| /_| | _ \ , , ,/ \ // | |/ `.\ ,- , , ,/ ,/ \/ / @| |@ / /' \ \ , > /| ,--. |\_/ \_/ / | | , ,/ \ ./' __:.. | __ __ | | | .--. , > > |-' / ` ,/| / ' \ | | | \ , | / / |<--.__,->| | | . `. > > / ( /_,' \\ ^ / \ / / `. >-- /^\ | \\___/ \ / / \__' \ \ \/ \ | `. |/ , , /`\ \ ) \ ' |/ , V \ / `-\ OpenBSD Puffy ---> `|/ ' V V \ \.' \_ '`-. V V \./'\ `|/-. \ / \ /,---`\ kat / `._____V_____V' ' '
$ doas pkg_add git go gmake
$ mkdir git $ cd git $ git clone https://github.com/mimecast/dtail $ cd dtail $ gmake
$ ./dtail --version DTail 4.1.0 Protocol 4.1 Have a lot of fun! $ file dtail dtail: ELF 64-bit LSB executable, x86-64, version 1
$ doas pkg_delete git go gmake
$ for bin in dserver dcat dgrep dmap dtail dtailhealth; do doas cp -p $bin /usr/local/bin/$bin doas chown root:wheel /usr/local/bin/$bin done
$ doas adduser -class nologin -group _dserver -batch _dserver $ doas usermod -d /var/run/dserver/ _dserver
$ cat <<'END' | doas tee /etc/rc.d/dserver #!/bin/ksh daemon="/usr/local/bin/dserver" daemon_flags="-cfg /etc/dserver/dtail.json" daemon_user="_dserver" . /etc/rc.d/rc.subr rc_reload=NO rc_pre() { install -d -o _dserver /var/log/dserver install -d -o _dserver /var/run/dserver/cache } rc_cmd $1 & END $ doas chmod 755 /etc/rc.d/dserver
desc 'Setup DTail'; task 'dtail', group => 'frontends', sub { my $restart = FALSE; file '/etc/rc.d/dserver': content => template('./etc/rc.d/dserver.tpl'), owner => 'root', group => 'wheel', mode => '755', on_change => sub { $restart = TRUE }; . . . . service 'dserver' => 'restart' if $restart; service 'dserver', ensure => 'started'; };
$ doas mkdir /etc/dserver $ curl https://raw.githubusercontent.com/mimecast/dtail/master/examples/dtail.json.examples | doas tee /etc/dserver/dtail.json
"Common": { "LogDir": "/var/log/dserver", "Logger": "Fout", "LogRotation": "Daily", "CacheDir": "cache", "SSHPort": 2222, "LogLevel": "Info" }
file '/etc/dserver', ensure => 'directory'; file '/etc/dserver/dtail.json', content => template('./etc/dserver/dtail.json.tpl'), owner => 'root', group => 'wheel', mode => '755', on_change => sub { $restart = TRUE };
$ cat <<'END' | doas tee /usr/local/bin/dserver-update-key-cache.sh #!/bin/ksh CACHEDIR=/var/run/dserver/cache DSERVER_USER=_dserver DSERVER_GROUP=_dserver echo 'Updating SSH key cache' ls /home/ | while read remoteuser; do keysfile=/home/$remoteuser/.ssh/authorized_keys if [ -f $keysfile ]; then cachefile=$CACHEDIR/$remoteuser.authorized_keys echo "Caching $keysfile -> $cachefile" cp $keysfile $cachefile chown $DSERVER_USER:$DSERVER_GROUP $cachefile chmod 600 $cachefile fi done # Cleanup obsolete public SSH keys find $CACHEDIR -name \*.authorized_keys -type f | while read cachefile; do remoteuser=$(basename $cachefile | cut -d. -f1) keysfile=/home/$remoteuser/.ssh/authorized_keys if [ ! -f $keysfile ]; then echo 'Deleting obsolete cache file $cachefile' rm $cachefile fi done echo 'All set...' END $ doas chmod 500 /usr/local/bin/dserver-update-key-cache.sh
$ echo /usr/local/bin/dserver-update-key-cache.sh | doas tee -a /etc/daily.local /usr/local/bin/dserver-update-key-cache.sh
file '/usr/local/bin/dserver-update-key-cache.sh', content => template('./scripts/dserver-update-key-cache.sh.tpl'), owner => 'root', group => 'wheel', mode => '500'; append_if_no_such_line '/etc/daily.local', '/usr/local/bin/dserver-update-key-cache.sh';
$ sudo rcctl enable dserver $ sudo rcctl start dserver $ tail -f /var/log/dserver/*.log INFO|1022-090634|Starting scheduled job runner after 2s INFO|1022-090634|Starting continuous job runner after 2s INFO|1022-090644|24204|stats.go:53|2|11|7|||MAPREDUCE:STATS|currentConnections=0|lifetimeConnections=0 INFO|1022-090654|24204|stats.go:53|2|11|7|||MAPREDUCE:STATS|currentConnections=0|lifetimeConnections=0 INFO|1022-090719|Starting server|DTail 4.1.0 Protocol 4.1 Have a lot of fun! INFO|1022-090719|Generating private server RSA host key INFO|1022-090719|Starting server INFO|1022-090719|Binding server|0.0.0.0:2222 INFO|1022-090719|Starting scheduled job runner after 2s INFO|1022-090719|Starting continuous job runner after 2s INFO|1022-090729|86050|stats.go:53|2|11|7|||MAPREDUCE:STATS|currentConnections=0|lifetimeConnections=0 INFO|1022-090739|86050|stats.go:53|2|11|7|||MAPREDUCE:STATS|currentConnections=0|lifetimeConnect . . . Ctr+C
$ doas /usr/local/bin/dserver-update-key-cache.sh Updating SSH key cache Caching /home/_dserver/.ssh/authorized_keys -> /var/cache/dserver/_dserver.authorized_keys Caching /home/admin/.ssh/authorized_keys -> /var/cache/dserver/admin.authorized_keys Caching /home/failunderd/.ssh/authorized_keys -> /var/cache/dserver/failunderd.authorized_keys Caching /home/git/.ssh/authorized_keys -> /var/cache/dserver/git.authorized_keys Caching /home/paul/.ssh/authorized_keys -> /var/cache/dserver/paul.authorized_keys Caching /home/rex/.ssh/authorized_keys -> /var/cache/dserver/rex.authorized_keys All set...
❯ ./dgrep -user rex -servers blowfish.buetow.org,fishfinger.buetow.org --regex local /etc/fstab CLIENT|earth|WARN|Encountered unknown host|{blowfish.buetow.org:2222 0xc0000a00f0 0xc0000a61e0 [blowfish.buetow.org]:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9ZnF/LAk14SgqCzk38yENVTNfqibcluMTuKx1u53cKSp2xwHWzy0Ni5smFPpJDIQQljQEJl14ZdXvhhjp1kKHxJ79ubqRtIXBlC0PhlnP8Kd+mVLLHYpH9VO4rnaSfHE1kBjWkI7U6lLc6ks4flgAgGTS5Bb7pLAjwdWg794GWcnRh6kSUEQd3SftANqQLgCunDcP2Vc4KR9R78zBmEzXH/OPzl/ANgNA6wWO2OoKKy2VrjwVAab6FW15h3Lr6rYIw3KztpG+UMmEj5ReexIjXi/jUptdnUFWspvAmzIl6kwzzF8ExVyT9D75JRuHvmxXKKjyJRxqb8UnSh2JD4JN [23.88.35.144]:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9ZnF/LAk14SgqCzk38yENVTNfqibcluMTuKx1u53cKSp2xwHWzy0Ni5smFPpJDIQQljQEJl14ZdXvhhjp1kKHxJ79ubqRtIXBlC0PhlnP8Kd+mVLLHYpH9VO4rnaSfHE1kBjWkI7U6lLc6ks4flgAgGTS5Bb7pLAjwdWg794GWcnRh6kSUEQd3SftANqQLgCunDcP2Vc4KR9R78zBmEzXH/OPzl/ANgNA6wWO2OoKKy2VrjwVAab6FW15h3Lr6rYIw3KztpG+UMmEj5ReexIjXi/jUptdnUFWspvAmzIl6kwzzF8ExVyT9D75JRuHvmxXKKjyJRxqb8UnSh2JD4JN 0xc0000a2180} CLIENT|earth|WARN|Encountered unknown host|{fishfinger.buetow.org:2222 0xc0000a0150 0xc000460110 [fishfinger.buetow.org]:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDNiikdL7+tWSN0rCaw1tOd9aQgeUFgb830V9ejkyJ5h93PKLCWZSMMCtiabc1aUeUZR//rZjcPHFLuLq/YC+Y3naYtGd6j8qVrcfG8jy3gCbs4tV9SZ9qd5E24mtYqYdGlee6JN6kEWhJxFkEwPfNlG+YAr3KC8lvEAE2JdWvaZavqsqMvHZtAX3b25WCBf2HGkyLZ+d9cnimRUOt+/+353BQFCEct/2mhMVlkr4I23CY6Tsufx0vtxx25nbFdZias6wmhxaE9p3LiWXygPWGU5iZ4RSQSImQz4zyOc9rnJeP1rwGk0OWDJhdKNXuf0kIPdzMfwxv2otgY32/DJj6L [46.23.94.99]:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDNiikdL7+tWSN0rCaw1tOd9aQgeUFgb830V9ejkyJ5h93PKLCWZSMMCtiabc1aUeUZR//rZjcPHFLuLq/YC+Y3naYtGd6j8qVrcfG8jy3gCbs4tV9SZ9qd5E24mtYqYdGlee6JN6kEWhJxFkEwPfNlG+YAr3KC8lvEAE2JdWvaZavqsqMvHZtAX3b25WCBf2HGkyLZ+d9cnimRUOt+/+353BQFCEct/2mhMVlkr4I23CY6Tsufx0vtxx25nbFdZias6wmhxaE9p3LiWXygPWGU5iZ4RSQSImQz4zyOc9rnJeP1rwGk0OWDJhdKNXuf0kIPdzMfwxv2otgY32/DJj6L 0xc0000a2240} Encountered 2 unknown hosts: 'blowfish.buetow.org:2222,fishfinger.buetow.org:2222' Do you want to trust these hosts?? (y=yes,a=all,n=no,d=details): a CLIENT|earth|INFO|STATS:STATS|cgocalls=11|cpu=8|connected=2|servers=2|connected%=100|new=2|throttle=0|goroutines=19 CLIENT|earth|INFO|Added hosts to known hosts file|/home/paul/.ssh/known_hosts REMOTE|blowfish|100|7|fstab|31bfd9d9a6788844.h /usr/local ffs rw,wxallowed,nodev 1 2 REMOTE|fishfinger|100|7|fstab|093f510ec5c0f512.h /usr/local ffs rw,wxallowed,nodev 1 2
❯ ./dgrep -user rex -servers blowfish.buetow.org,fishfinger.buetow.org --regex local /etc/fstab REMOTE|blowfish|100|7|fstab|31bfd9d9a6788844.h /usr/local ffs rw,wxallowed,nodev 1 2 REMOTE|fishfinger|100|7|fstab|093f510ec5c0f512.h /usr/local ffs rw,wxallowed,nodev 1 2