nixops:在具有现有nixos(targetEnv为none)的计算机上进行部署时,如何使用本地ssh密钥?

时间:2018-08-05 12:59:43

标签: nixops

我有使用nixos的计算机(使用terraform,config进行了配置),我想使用deployment.targetHost = ipAddressdeployment.targetEnv = "none"连接到它

但是我无法将nixops配置为使用/secrets/stage_ssh_key ssh键

这不起作用(实际上没有记录,我在这里https://github.com/NixOS/nixops/blob/d4e5b779def1fc9e7cf124930d0148e6bd670051/nixops/backends/none.py#L33-L35找到了)

{
  stage =
    { pkgs, ... }:
    {
      deployment.targetHost = (import ./nixos-generated/stage.nix).terraform.ip;
      deployment.targetEnv = "none";

      deployment.none.sshPrivateKey        = builtins.readFile ./secrets/stage_ssh_key;
      deployment.none.sshPublicKey         = builtins.readFile ./secrets/stage_ssh_key.pub;
      deployment.none.sshPublicKeyDeployed = true;

      environment.systemPackages = with pkgs; [
        file
      ];
    };
}

nixops ssh stage导致要求输入密码-无需密码即可登录

nixops ssh stage -i ./secrets/stage_ssh_key正常工作,不要求输入密码

如何复制:

  • 下载存储库
  • rm -rf secrets/*
  • secrets/aws.nix

    中添加AWS键

    { EC2_ACCESS_KEY="XXXX"; EC2_SECRET_KEY="XXXX"; }

  • nix-shell

  • make generate_stage_ssh_key
  • terraform apply
  • make nixops_create
  • nixops deploy询问密码

0 个答案:

没有答案