2019-12-01 05:23:06 +01:00
|
|
|
{
|
2021-11-01 19:30:41 +01:00
|
|
|
# cat ~/.ssh/id_rsa.pub
|
|
|
|
publicSshKey ? ""
|
|
|
|
, # remote-install-get-hiddenReceiver
|
|
|
|
hiddenReceiver ? ""
|
|
|
|
,
|
|
|
|
}:
|
2019-12-20 05:54:26 +01:00
|
|
|
{ config, lib, pkgs, ... }: {
|
2019-12-01 05:23:06 +01:00
|
|
|
|
|
|
|
imports = [
|
2021-11-01 19:30:41 +01:00
|
|
|
{
|
|
|
|
# system setup
|
2019-12-01 05:23:06 +01:00
|
|
|
networking.hostName = "liveos";
|
|
|
|
|
|
|
|
users.extraUsers = {
|
2019-12-20 05:54:26 +01:00
|
|
|
root = { openssh.authorizedKeys.keys = [ publicSshKey ]; };
|
2019-12-01 05:23:06 +01:00
|
|
|
};
|
|
|
|
}
|
2021-11-01 19:30:41 +01:00
|
|
|
{
|
|
|
|
# installed packages
|
2019-12-01 05:23:06 +01:00
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
environment.systemPackages = with pkgs; [
|
2019-12-20 05:54:26 +01:00
|
|
|
#style
|
2019-12-01 05:23:06 +01:00
|
|
|
most
|
|
|
|
rxvt_unicode.terminfo
|
|
|
|
|
2019-12-20 05:54:26 +01:00
|
|
|
#monitoring tools
|
2019-12-01 05:23:06 +01:00
|
|
|
htop
|
|
|
|
iotop
|
|
|
|
|
2019-12-20 05:54:26 +01:00
|
|
|
#network
|
2019-12-01 05:23:06 +01:00
|
|
|
iptables
|
|
|
|
iftop
|
|
|
|
nmap
|
|
|
|
|
2019-12-20 05:54:26 +01:00
|
|
|
#stuff for dl
|
2019-12-01 05:23:06 +01:00
|
|
|
aria2
|
|
|
|
|
2019-12-20 05:54:26 +01:00
|
|
|
#neat utils
|
2019-12-01 05:23:06 +01:00
|
|
|
pciutils
|
|
|
|
psmisc
|
|
|
|
tmux
|
|
|
|
usbutils
|
|
|
|
git
|
|
|
|
|
2019-12-20 05:54:26 +01:00
|
|
|
#unpack stuff
|
2019-12-01 05:23:06 +01:00
|
|
|
p7zip
|
|
|
|
unzip
|
|
|
|
unrar
|
|
|
|
|
2019-12-20 05:54:26 +01:00
|
|
|
#data recovery
|
2019-12-01 05:23:06 +01:00
|
|
|
ddrescue
|
|
|
|
ntfs3g
|
|
|
|
dosfstools
|
|
|
|
];
|
|
|
|
}
|
2021-11-01 19:30:41 +01:00
|
|
|
{
|
|
|
|
# bash configuration
|
2019-12-01 05:23:06 +01:00
|
|
|
programs.bash = {
|
|
|
|
enableCompletion = true;
|
|
|
|
interactiveShellInit = ''
|
|
|
|
HISTCONTROL='erasedups:ignorespace'
|
|
|
|
HISTSIZE=65536
|
|
|
|
HISTFILESIZE=$HISTSIZE
|
|
|
|
|
|
|
|
shopt -s checkhash
|
|
|
|
shopt -s histappend histreedit histverify
|
|
|
|
shopt -s no_empty_cmd_completion
|
|
|
|
complete -d cd
|
|
|
|
'';
|
|
|
|
promptInit = ''
|
|
|
|
if test $UID = 0; then
|
|
|
|
PS1='\[\033[1;31m\]\w\[\033[0m\] '
|
|
|
|
PROMPT_COMMAND='echo -ne "\033]0;$$ $USER@$PWD\007"'
|
|
|
|
elif test $UID = 1337; then
|
|
|
|
PS1='\[\033[1;32m\]\w\[\033[0m\] '
|
|
|
|
PROMPT_COMMAND='echo -ne "\033]0;$$ $PWD\007"'
|
|
|
|
else
|
|
|
|
PS1='\[\033[1;33m\]\u@\w\[\033[0m\] '
|
|
|
|
PROMPT_COMMAND='echo -ne "\033]0;$$ $USER@$PWD\007"'
|
|
|
|
fi
|
|
|
|
if test -n "$SSH_CLIENT"; then
|
|
|
|
PS1='\[\033[35m\]\h'" $PS1"
|
|
|
|
PROMPT_COMMAND='echo -ne "\033]0;$$ $HOSTNAME $USER@$PWD\007"'
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|
2021-11-01 19:30:41 +01:00
|
|
|
{
|
|
|
|
# ssh configuration
|
2019-12-01 05:23:06 +01:00
|
|
|
services.openssh.enable = true;
|
|
|
|
services.openssh.passwordAuthentication = false;
|
|
|
|
systemd.services.sshd.wantedBy = lib.mkForce [ "multi-user.target" ];
|
|
|
|
}
|
2021-11-01 19:30:41 +01:00
|
|
|
{
|
|
|
|
# hidden ssh announce
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
torDirectory = "/var/lib/tor";
|
2022-09-23 20:29:18 +02:00
|
|
|
hiddenServiceDir = torDirectory + "/onion/hidden-ssh";
|
2021-11-01 19:30:41 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
services.tor = {
|
|
|
|
enable = true;
|
|
|
|
client.enable = true;
|
2022-09-23 20:29:18 +02:00
|
|
|
relay.onionServices.hidden-ssh = {
|
|
|
|
version = 3;
|
|
|
|
map = [{
|
|
|
|
port = 22;
|
|
|
|
target.port = 22;
|
|
|
|
}];
|
|
|
|
};
|
2021-11-01 19:30:41 +01:00
|
|
|
};
|
|
|
|
systemd.services.hidden-ssh-announce = {
|
|
|
|
description = "irc announce hidden ssh";
|
|
|
|
after = [ "tor.service" "network-online.target" ];
|
|
|
|
wants = [ "tor.service" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = pkgs.writers.writeDash "irc-announce-ssh" ''
|
|
|
|
set -efu
|
|
|
|
until test -e ${hiddenServiceDir}/hostname; do
|
|
|
|
echo "still waiting for ${hiddenServiceDir}/hostname"
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
until ${pkgs.tor}/bin/torify ${pkgs.netcat-openbsd}/bin/nc -z ${hiddenReceiver} 1337; do sleep 1; done && \
|
|
|
|
echo "torify ssh root@$(cat ${hiddenServiceDir}/hostname) -i ~/.ssh/id_rsa" | ${pkgs.tor}/bin/torify ${pkgs.nmap}/bin/ncat ${hiddenReceiver} 1337
|
|
|
|
'';
|
|
|
|
PrivateTmp = "true";
|
|
|
|
User = "tor";
|
|
|
|
Type = "oneshot";
|
|
|
|
};
|
2019-12-01 05:23:06 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|