k 3 hidden-ssh: init

This commit is contained in:
makefu 2017-04-15 18:04:19 +02:00
parent c45cd788d2
commit 4feb0e8e91
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225
2 changed files with 54 additions and 0 deletions

View File

@ -20,6 +20,7 @@ let
./github-hosts-sync.nix ./github-hosts-sync.nix
./git.nix ./git.nix
./go.nix ./go.nix
./hidden-ssh.nix
./htgen.nix ./htgen.nix
./iptables.nix ./iptables.nix
./kapacitor.nix ./kapacitor.nix

View File

@ -0,0 +1,53 @@
{ config, lib, pkgs, ... }:
with import <stockholm/lib>;
let
cfg = config.krebs.hidden-ssh;
out = {
options.krebs.hidden-ssh = api;
config = lib.mkIf cfg.enable imp;
};
api = {
enable = mkEnableOption "hidden SSH announce";
};
imp = let
torDirectory = "/var/lib/tor"; # from tor.nix
hiddenServiceDir = torDirectory + "/ssh-announce-service";
in {
services.tor = {
enable = true;
extraConfig = ''
HiddenServiceDir ${hiddenServiceDir}
HiddenServicePort 22 127.0.0.1:22
'';
client.enable = true;
};
systemd.services.hidden-ssh-announce = {
description = "irc announce hidden ssh";
after = [ "tor.service" ];
wants = [ "tor.service" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
# ${pkgs.tor}/bin/torify
ExecStart = pkgs.writeDash "irc-announce-ssh" ''
set -efu
until test -e ${hiddenServiceDir}/hostname; do
echo "still waiting for ${hiddenServiceDir}/hostname"
sleep 1
done
${pkgs.irc-announce}/bin/irc-announce \
irc.freenode.org 6667 ${config.krebs.build.host.name}-ssh \
\#krebs-announce \
"SSH Hidden Service at $(cat ${hiddenServiceDir}/hostname)"
'';
PrivateTmp = "true";
User = "tor";
Type = "oneshot";
};
};
};
in
out