From 95dcf26f68d2eb357bccabc02f025db73c517d37 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Mon, 10 Dec 2018 23:11:44 +0000 Subject: [PATCH] Don't assume virtual box deployments when copying authorized keys --- modules/nixbitcoin.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/nixbitcoin.nix b/modules/nixbitcoin.nix index fdc15bb..3eafeb9 100644 --- a/modules/nixbitcoin.nix +++ b/modules/nixbitcoin.nix @@ -19,6 +19,16 @@ let nodejs-8_x nginx ]; + operatorCopySSH = pkgs.writeText "operator-copy-ssh.sh" '' + mkdir -p ${config.users.users.operator.home}/.ssh + if [ -e "${config.users.users.root.home}/.vbox-nixops-client-key" ]; then + cp ${config.users.users.root.home}/.vbox-nixops-client-key ${config.users.users.operator.home}/.ssh/authorized_keys + fi + if [ -e "/etc/ssh/authorized_keys.d/root" ]; then + cat /etc/ssh/authorized_keys.d/root >> ${config.users.users.operator.home}/.ssh/authorized_keys + fi + chown -R operator ${config.users.users.operator.home}/.ssh + ''; in { imports = [ @@ -113,7 +123,7 @@ in { wantedBy = [ "multi-user.target" ]; path = [ ]; serviceConfig = { - ExecStart = "${pkgs.bash}/bin/bash -c \"mkdir -p ${config.users.users.operator.home}/.ssh && cp ${config.users.users.root.home}/.vbox-nixops-client-key ${config.users.users.operator.home}/.ssh/authorized_keys && chown -R operator ${config.users.users.operator.home}/.ssh\""; + ExecStart = "${pkgs.bash}/bin/bash \"${operatorCopySSH}\""; user = "root"; type = "oneshot"; };