summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2013-02-07 20:26:15 +0100
committermakefu <github@syntax-fehler.de>2013-02-07 20:26:15 +0100
commitdd6ad821a5a5bcb633b28a6d35e5e612d1f59094 (patch)
tree51a5281d1cbba3423eb5e9a86eb16d847fac5a6e /services
parent12fa3df06555c4ad6973602998a42446fbb52e70 (diff)
parent41fb505a5dc5c81965cc45dd00d14fe4150b8a42 (diff)
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'services')
-rw-r--r--services/Makefile3
-rw-r--r--services/README.md25
-rwxr-xr-xservices/bin/services11
-rw-r--r--services/etc/conf.d/krebs-services-test-server3
-rw-r--r--services/etc/services/bootstrap9
-rw-r--r--services/etc/systemd/system/krebs-services-test-server.service14
-rw-r--r--services/services.txt4
-rwxr-xr-x[-rw-r--r--]services/test-server.py (renamed from services/test.py)10
8 files changed, 71 insertions, 8 deletions
diff --git a/services/Makefile b/services/Makefile
index 3ef670a3..37931f47 100644
--- a/services/Makefile
+++ b/services/Makefile
@@ -1,5 +1,6 @@
help:;@cat Makefile
export authorized_keys_file := authorized_keys
+export debug_log := true
export services_file := services.txt
export host_key_file := test.key
export services_home := /opt/services
@@ -32,7 +33,7 @@ test-client:
ssh localhost -p 1337 2>/dev/null
test-server:
- python test.py
+ ./test-server.py
$(host_key_file):
ssh-keygen -t rsa -P '' -f $@
diff --git a/services/README.md b/services/README.md
new file mode 100644
index 00000000..e0769bce
--- /dev/null
+++ b/services/README.md
@@ -0,0 +1,25 @@
+# //services
+
+## install and run test-server.py as systemd service
+
+### install dependencies
+
+ pacman -S python2-pyasn1 twisted
+
+### install systemd service and configuration
+
+ cp /krebs/services/etc/systemd/system/krebs-services-test-server.service \
+ /etc/systemd/system/
+ cp /krebs/services/etc/conf.d/krebs-services-test-server \
+ /etc/conf.d/
+
+### create services user and populate it's home
+
+ useradd -m -r -l -f -1 -d /opt/services -k /var/empty services
+ sudo -u services ssh-keygen -t rsa -P '' -f /opt/services/test.key
+ $EDITOR /opt/services/services.txt
+
+### run now and every reboot
+
+ systemctl start krebs-services-test-server
+ systemctl enable krebs-services-test-server
diff --git a/services/bin/services b/services/bin/services
index c142a363..e854cbcb 100755
--- a/services/bin/services
+++ b/services/bin/services
@@ -8,6 +8,8 @@ user=services
hostname=${1-localhost}
port=1337
+options="${options+$options }-o ControlMaster=no"
+
if test -n "${services_identity_file-}"; then
options="${options+$options }-i $services_identity_file"
fi
@@ -21,4 +23,11 @@ if echo $hostname | grep -q :; then
hostname=`echo $hostname | cut -d: -f1`
fi
-ssh $options $user@$hostname -p $port
+exec 3>&1
+{
+ ssh $options $user@$hostname -p $port
+} 2>&1 1>&3 | sed '
+ /^Connection to '$hostname' closed/d
+ /^Shared connection to '$hostname' closed/d
+'
+exec 3>&-
diff --git a/services/etc/conf.d/krebs-services-test-server b/services/etc/conf.d/krebs-services-test-server
new file mode 100644
index 00000000..243054f4
--- /dev/null
+++ b/services/etc/conf.d/krebs-services-test-server
@@ -0,0 +1,3 @@
+authorized_keys_file=/krebs/services/authorized_keys
+services_file=/opt/services/services.txt
+host_key_file=/opt/services/test.key
diff --git a/services/etc/services/bootstrap b/services/etc/services/bootstrap
new file mode 100644
index 00000000..8c848146
--- /dev/null
+++ b/services/etc/services/bootstrap
@@ -0,0 +1,9 @@
+services://destroy
+services://ire
+services://darth_serious:22
+services://pigstarter:22
+services://incept:22
+services://rage:22
+services://devstar:22
+services://heidi:22
+services://geisha:22
diff --git a/services/etc/systemd/system/krebs-services-test-server.service b/services/etc/systemd/system/krebs-services-test-server.service
new file mode 100644
index 00000000..99578cce
--- /dev/null
+++ b/services/etc/systemd/system/krebs-services-test-server.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=services: provider
+After=network.target
+
+[Service]
+EnvironmentFile=/etc/conf.d/krebs-services-test-server
+ExecStart=/krebs/services/test-server.py
+KillMode=process
+User=services
+Group=services
+Restart=no
+
+[Install]
+WantedBy=multi-user.target
diff --git a/services/services.txt b/services/services.txt
index dc88cbac..265e6d1c 100644
--- a/services/services.txt
+++ b/services/services.txt
@@ -3,5 +3,5 @@ type:
mail:
expires:
location:
-services://{{hostname}}:22/
-tinc://{{hostname}}/
+services://{{hostname}}:22
+tinc://{{hostname}}
diff --git a/services/test.py b/services/test-server.py
index 06340a54..7838e0af 100644..100755
--- a/services/test.py
+++ b/services/test-server.py
@@ -1,8 +1,9 @@
-#! /usr/bin/env python
+#! /usr/bin/env python2
from os import environ as env
authorized_keys_file = env.get('authorized_keys_file', '/dev/null')
+debug_log = env.get('debug_log', 'false')
services_file = env.get('services_file', '/dev/null')
host_key_file = env.get('host_key_file', '/dev/null')
host_key_pub_file = host_key_file + '.pub'
@@ -22,9 +23,10 @@ from twisted.internet.reactor import listenTCP, run
from twisted.python.components import registerAdapter
from zope.interface import implements
-from twisted.python.log import startLogging
-from sys import stderr
-startLogging(stderr)
+if debug_log == 'true':
+ from twisted.python.log import startLogging
+ from sys import stderr
+ startLogging(stderr)
class MyRealm: