Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSHD doesn't work. #26776

Closed
MrSorcus opened this issue Jun 22, 2017 · 14 comments · Fixed by #63773
Closed

SSHD doesn't work. #26776

MrSorcus opened this issue Jun 22, 2017 · 14 comments · Fixed by #63773
Labels
2.status: wontfix We cannot or will not fix this issue 9.needs: documentation

Comments

@MrSorcus
Copy link

Steps to reproduce

1:
cat ./custom.nix

{ config, lib, pkgs, ... }:

{
  imports = [ ./modules/installer/cd-dvd/installation-cd-base.nix ];

        users.extraUsers.root.openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAA... sorcus@laptop" ];

        systemd.network.enable = true;
        systemd.network.networks.wired.name = "enp0s3";
        systemd.network.networks.wired.address = [ "2a01:***:***::13/64" ];
        systemd.network.networks.wired.gateway = [ "fe80::1" ];

        services.openssh.enable = true;
}

2:
nix-build -A config.system.build.isoImage -I nixos-config=./custom.nix ./default.nix

3:
Create virtual machine and run with nixos iso. SSH Daemon doesn't work. It's loaded, but not active.

4:
But it's working with services.openssh.startWhenNeeded = true; ... and show this warnings:

Jun 22 21:19:09 nixos systemd[1]: sshd.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 22 21:07:44 nixos systemd[1]: Started Session 3 of user root.
Jun 22 21:07:50 nixos systemd[1]: sshd.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

Technical details

  • System: 17.09.git.c89efa3 (Hummingbird)
  • Nix version: nix-env (Nix) 1.11.11
  • Nixpkgs version: 17.09.git.c89efa3
  • Sandboxing enabled: build-use-sandbox = false
@vcunat
Copy link
Member

vcunat commented Jun 22, 2017

And why is it wrong? It's even documented: http://nixos.org/nixos/manual/#sec-installation (7.)

@aszlig
Copy link
Member

aszlig commented Jun 23, 2017

@vcunat: He provided authorizedKeys, so it should work without setting a root password. We even have tests doing exactly that, but without the installer CD import, so I'm guessing the real issue here could be the latter.

@aszlig
Copy link
Member

aszlig commented Jun 23, 2017

The actual problem here is this line, so @MrSorcus adding the following line in your configuration should fix that:

systemd.services.sshd.wantedBy = lib.mkOverride 40 [ "multi-user.target" ];

For the installer image it makes sense to remove sshd from multi-user.target, because it allows the user to optionally enable openssh at runtime via systemctl start sshd.

@vcunat
Copy link
Member

vcunat commented Jun 23, 2017

To be clear, I meant the fact that you have to start sshd manually on an installation system. I can see nothing wrong about that. (Perhaps I misunderstood.)

@aszlig
Copy link
Member

aszlig commented Jun 23, 2017

@vcunat: No, I was wrong about that, I only read point 7 regarding setting the root passwd.

@Mic92
Copy link
Member

Mic92 commented Jun 23, 2017

@Mic92
Copy link
Member

Mic92 commented Jun 23, 2017

The warnings when using services.openssh.startWhenNeeded can be ignored.
I would say it is not a bug, but intended behavior.

@Mic92 Mic92 added 2.status: wontfix We cannot or will not fix this issue 9.needs: documentation labels Jun 23, 2017
@MrSorcus
Copy link
Author

MrSorcus commented Jun 23, 2017

@Mic92 , maybe not a bug, but an error.

[root@nixos:~]# systemctl status sshd
● sshd.service
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)

Jun 23 09:55:46 nixos systemd[1]: sshd.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
[root@nixos:~]# systemctl cat sshd
# /nix/store/6bidvr31m3nz0cq7z3xivjdgvyhg36zs-unit-sshd.service/sshd.service
[Unit]

[Service]
Environment="LOCALE_ARCHIVE=/nix/store/lzzhb68wykc1kbf1wjcj1vfjhimwvgsf-glibc-locales-2.25/lib/locale/locale-archive"
Environment="PATH=/nix/store/v64g1yg79b4i3cc7ajxzi5gik4sq2737-coreutils-8.27/bin:/nix/store/pzniwigry771hvqqlr939jmddcqh79m6-findutils-4.6.0/bin:/nix/store/96kg25hm8m95
Environment="TZDIR=/nix/store/gxcxsd0qgmn1qd6v655sikc92rgkqwl6-tzdata-2016j/share/zoneinfo"

@MrSorcus
Copy link
Author

@aszlig , thank you.
systemd.services.sshd.wantedBy = lib.mkOverride 40 [ "multi-user.target" ]; work very well without any problems.

@tomberek
Copy link
Contributor

Close as answered?

@MrSorcus
Copy link
Author

Close as answered?

I don't know.
@Mic92 is it fixed in documentation?

@Mic92
Copy link
Member

Mic92 commented Oct 11, 2018

Probably not.

@elmarx
Copy link
Member

elmarx commented Oct 31, 2018

https://nixos.wiki/wiki/Creating_a_NixOS_live_CD works flawlessly.

@flokli
Copy link
Contributor

flokli commented Jun 29, 2019

A fix for this is in progress at #63773.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: wontfix We cannot or will not fix this issue 9.needs: documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants