34 lines
1.4 KiB
Nix
34 lines
1.4 KiB
Nix
{ pkgs ? import <nixpkgs> {} }:
|
|
|
|
let utils = import ../deployment/utils.nix {} ;
|
|
files = [
|
|
(utils.copy ./flag.txt "home/joske/flag.txt")
|
|
(pkgs.writeTextDir "home/joske/.ssh/authorized_keys" ''
|
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDO2F8WY5XTTcCapt0QhOOAetHTkdBJo+mc/bJ6oRg/0FJ9Ro74yZxcqOTbyEPf/khg9qY9TKf121CaXvJJSLmv3U20X15UlHnDPrh+EsRiCMaiMGd/N+l1ZQ+grj1klcblYxSt7nKtLhh36JaC9A6olFF8ahzcm1Rl69tE4bLdKqALpAbhbTmTlofIH1dzGDF31EfJeLZnuV5XRLq9XCF2YJkbyUJjeBs+4iHQFWxZFfYZJBMAYFLkNrmYvsKjwgwHBEC/g2nCRvW/0KhkXl/N8NU5jXw67Snf/unqD8JmC7Or3GgKT6+sdthbi2dWO4beSEnVoijmvFt+2uwSwU97tij7a7j6Z+J7ekkDDbt8Due1CxNL7sBcIbB22ELC0WwpEijzYC+RaCtiRegzEuGJui9wdjX7kOKxEobSVfSHgzzrT6FJWdThnQ4SZ2vsF6Yt5OjyXNI5TRiNv9DZAYdK6KNyxsxjEmkVZc1JGAsWzdq/GcBH1MilrK5w97JYat8= nibor@Rylia
|
|
'')
|
|
] ;
|
|
in
|
|
pkgs.dockerTools.buildImage {
|
|
name = "lost-keys";
|
|
tag = "latest";
|
|
contents = files ++ [ pkgs.busybox ];
|
|
runAsRoot = ''
|
|
${pkgs.dockerTools.shadowSetup}
|
|
useradd -U -m joske
|
|
mkdir -p /home/joske/
|
|
chown -R joske:joske /home/joske/
|
|
echo "joske:hvfu7s7xBNGe6Rxa" | chpasswd
|
|
mkdir -p /root
|
|
${pkgs.dropbear}/bin/dropbearkey -t rsa -f /root/hostkey
|
|
chmod o-r /root/hostkey
|
|
chmod -R -w /home/joske/
|
|
'';
|
|
|
|
config = {
|
|
ExposedPorts = {
|
|
"2222/tcp" = {};
|
|
};
|
|
Cmd = [ "${pkgs.dropbear}/bin/dropbear" "-r" "/root/hostkey" "-F" "-g" "-j" "-k" "-p" "2222" ];
|
|
};
|
|
}
|