Giter Site home page Giter Site logo

dracut-sshd's Introduction

Copr Build Status

This Dracut module (dracut-sshd) integrates the OpenSSH sshd into the initramfs. It allows for remote unlocking of a fully encrypted root filesystem and remote access to the Dracut emergency shell (i.e. early userspace).

It's compatible with systems that use Dracut as initramfs manager and systemd as init system, such as Fedora, CentOS/RHEL (version 7 or greater) and SUSE. Gentoo is also to known to work with dracut-sshd, as long as it's configured with systemd and Dracut.

2018, Georg Sauthoff [email protected], GPLv3+

TOC

Example: Open Encrypted Root Filesystem

After booting a Fedora system with encrypted root filesystem (i.e. a filesystem on a LUKS volume to be opened with cryptsetup) the Dracut initramfs blocks at the password prompt. With dracut-sshd enabled remote unlocking is then as simple as:

$ ssh headless.example.org
-sh-4.4# systemd-tty-ask-password-agent       
Please enter passphrase for disk luks-123-cafe! *********
Please enter passphrase for disk luks-124-cafe! *********
-sh-4.4# Connection to 203.0.113.23 closed by remote host.
Connection to 203.0.113.23 closed.

That means under normal circumstances the completion of all password prompts automatically resumes the boot process.

The command systemd-tty-ask-password-agent --list prints an overview over all pending password prompts.

Example: Emergency Shell

The start of the Dracut emergency shell can be requested via adding rd.break to the kernel command line, but it also happens when Dracut is unable to mount the root filesystem or other grave issues. In such cases the emergency shell blocks the boot process. Without remote access the machine is quite dead then.

Example session:

$ ssh headless.example.org
-sh-4.4# export TERM=vt220
-sh-4.4# export SYSTEMD=FRMXK
-sh-4.4# export LC_ALL=C
-sh-4.4# less /run/initramfs/rdsosreport.txt
-sh-4.4# journalctl -e
-sh-4.4# systemctl status
-sh-4.4# systemctl list-jobs

After fixing potential issues the emergency shell can be terminated to resume the boot:

switch_root:/root# systemctl stop dracut-emergency.service
switch_root:/root# Connection to 203.0.113.23 closed by remote host.
Connection to 203.0.113.23 closed.

Alternatively, one can send a signal to the emergency service, e.g. with systemctl kill ... or systemctl kill --signal=... ....

Install

Copy the 46sshd subdirectory to the Dracut module directory:

# cp -ri 46sshd /usr/lib/dracut/modules.d

Alternatively, you can install the latest stable version from the dracut-sshd copr repository.

Either way, once present under /usr/lib/dracut/modules.d it's enabled, by default.

With an sshd that lacks systemd support (e.g. under Gentoo), one has to adjust the systemd service file:

# echo 'Skip this sed on Fedora/RHEL/CentOS/Debian/Ubuntu/...!'
# sed -e 's/^Type=notify/Type=simple/' \
      -e 's@^\(ExecStart=/usr/sbin/sshd\) -D@\1 -e -D@' \
      -i \
      /usr/lib/dracut/modules.d/46sshd/sshd.service

Dracut-sshd includes the first available ssh authorized keys file of the following list into the initramfs:

  • /root/.ssh/dracut_authorized_keys
  • /etc/dracut-sshd/authorized_keys
  • /root/.ssh/authorized_keys

Note that on some distributions such as Fedora Silverblue your only option is to create a keys file under /etc/dracut-sshd as /root isn't accessible during dracut runtime.

Of course, our initramfs image needs network support. The simplest way to achieve this is to include networkd. To install the networkd dracut module:

# dnf install -y dracut-network

When installing from copr, dracut-network is automatically installed as dependency.

Create a non-NetworkManager network config, e.g. via Networkd:

$ cat /etc/systemd/network/20-wired.network
[Match]
Name=e*

[Network]
DHCP=ipv4

Adjust the Name=, if necessary.

Note that the dracut networkd module doesn't include the system's network configuration files by default and note that the module isn't enabled, by default, either. Thus, you have to configure Dracut for networkd (cf. the install_items and add_dracutmodules directives). Example:

# cat /etc/dracut.conf.d/90-networkd.conf
install_items+=" /etc/systemd/network/20-wired.network "
add_dracutmodules+=" systemd-networkd "

Alternatively, early boot network connectivity can be configured by other means (i.e. kernel parameters, see below). However, the author of this README strongly recommends to use Networkd instead of NetworkManager on servers and server-like systems.

If the above example is sufficient you just need to copy the example configuration files from the example/ subdirectory:

# cp example/20-wired.network  /etc/systemd/network
# cp example/90-networkd.conf /etc/dracut.conf.d

Finally regenerate the initramfs:

# dracut -f -v

Note that Ubuntu's dracut defaults to an initramfs filename that is incompatible with Ubuntu's grub default initrd settings ... m( Thus, on Ubuntu one has to explicitly specify the initramfs filename like this:

# dracut -f -v /boot/initrd.img-$(uname -r)

Verify that this sshd module is included. Either via inspecting the verbose output or via lsinitrd, e.g.:

# lsinitrd | grep 'authorized\|bin/sshd\|network/20'
-rw-r--r--   1 root     root          119 Jul 17 15:08 etc/systemd/network/20-wired.network
-rw-------   1 root     root           99 Jul 17 17:04 root/.ssh/authorized_keys
-rwxr-xr-x   1 root     root       876328 Jul 17 17:04 usr/sbin/sshd

Finally, reboot.

Space Overhead

The space overhead of the Dracut sshd module is negligible:

enabled modules           initramfs size
--------------------------------------
vanilla -network -ifcfg   16 MiB
+systemd-networkd         17 MiB
+systemd-networkd +sshd   19 MiB
+network +ifcfg           21 MiB
+network +ifcfg +sshd     21 MiB
+network +ifcfg +sshd     22 MiB
+systemd-networkd

(all numbers from a Fedora 28 system, measuring the compressed initramfs size)

Technically, the systemd-networkd Dracut module is sufficient for establishing network connectivity. It even includes the ip command. Since the network Dracut module is included by default (under CentOS 7/Fedora 27/28) via the ifcfg Dracut module, it may make sense to explicitly exclude it when building the initramfs on a system where networkd is available, e.g. via

dracut -f -v --omit ifcfg

as this saves a few megabytes.

Since the initramfs is actually loaded into a tmpfs that is freed during switch-root it doesn't really pay off to safe a few mega-/kilobytes in the initramfs. A few KiBs could be saved via switching from OpenSSH's sshd to something like Dropbear, but such an alternative sshd server is likely less well audited for security issues and supports less features (e.g. ssh-ed25519 public key authentication was only added as late as 2020, and, as of 2021, there are some interoperability issues and ed25519-sk keys aren't supported).

Last but not least, in times where even embedded systems feature hundreds of megabytes RAM, temporarily occupying a few extra KiBs/MiBs before switch root has no dramatic impact.

Host Keys

By default, this module includes the system's /etc/ssh/ssh_host_*_key private host keys into the initramfs. Note that this doesn't decrease the security in comparison with a system whose root filesystem is unencrypted:

  • the generated initramfs image under /boot is only readable by the root user
  • if an attacker is able to access the /boot/initramfs file (e.g. by booting the machine from a Live stick) then she is also able to access all host keys on a unencrypted root filesystem

That said, if /etc/ssh/dracut_ssh_host_*_key{,.pub} files are present then those are included, instead.

As always, it depends on your threat model, whether it makes sense to use an extra host key for the initramfs or not. Using an extra key may complicate the life of an attacker who is able to read out the initramfs content but is unable to change it and thus the attacker has to wait for the next SSH connection to the initramfs before being able to perform a MITM attack. On the other hand, when the attacker is able to change to initramfs image then an extra key doesn't provide more security than using the system's host key as the attacker can intercept the entered password, anyway.

If your primary threat model is an attacker who gets access to decommissioned but still readable hard-disks, then the system's host key in the initramfs image provides no value to the attacker given that the root filesystem is fully encrypted (and that the host key isn't reused in the replacement system).

Timeout

With recent Fedora versions (e.g. Fedora 28) a cryptsetup password prompt shouldn't timeout. If it does then it's a regression (cf. Bug 868421). Even if it times out and Dracut drops into the emergency shell then remotely connecting to it should still work with this module. In such situations systemd-tty-ask-password-agent should still work. See also Section 'Example: Emergency Shell' on how to resume the boot process then.

A simple way to trigger the timeout is to enter the wrong password 3 times when unlocking a LUKS volume. Under Fedora 28, the timeout is then 2 minutes or so long, i.e. the emergency shell is then started after 2 minutes, by default, even without explicitly adding rd.shell to the kernel command line. One can recover from such a situation with e.g.:

# systemctl restart 'systemd-cryptsetup@*'

Another example for the emergency shell getting started is that a device that is necessary for mounting the root filesystem simply isn't attached - or the UUIDs specified on the kernel command line don't match. After inspecting the situation with systemctl status ..., journalctl -e, etc. one can regenerate some config and restart the appropriate services in a similar fashion.

Network

An alternative to the networkd configuration is to configure network via additional Dracut command line parameters.

This requires the activation of the network dracut module, e.g.:

# cat /etc/dracut.conf.d/90-network.conf
add_dracutmodules+=" network "

On systems without networkd (e.g. CentOS 7/RHEL 8) this is the only way to enable network connectivity in early userspace. For example, the following parameters enable DHCP on all network interfaces in early userspace:

rd.neednet=1 ip=dhcp

They need to be appended to GRUB_CMDLINE_LINUX= in /etc/default/grub and to be effective the Grub config then needs to be regenerated:

# grub2-editenv - unset kernelopts
# grub2-mkconfig -o /etc/grub2.cfg
# grub2-mkconfig -o /etc/grub2-efi.cfg

Note that on distributions like CentOS 7/Fedora 27/28 there is also the old-school ifcfg network scripts system under /etc/sysconfig/network-scripts that can be used instead of NetworkManager. It can be launched via the auto-generated network service that calls the old sysv init.d script. However, the network Dracut module doesn't include neither this service nor the network-scripts configuration (it includes some of the scripts but the Dracut modules auto-generate the configuration during early userspace boot based on the kernel command line/detected hardware). With CentOS 7/Fedora 27/28 the default network configuration (in late userspace) uses NetworkManager which only uses the ifcfg-* files under /etc/sysconfig/network-scripts.

The grub2-editenv call is only necessary on systems (such as RHEL 8) where the kernel parameters are stored in /etc/grubenv instead of in each menu entry (either in the main grub2.cfg or under /boot/loader/entries if the system follows the boot loader specification (bls)).

Hardware Alternatives

A Baseboard Management Controller (BMC) or some kind of remote KVM device can help with early boot issues, however:

  • not all remote machines even have a BMC
  • the BMC often is quite tedious to use and buggy
  • the BMC often contains low quality proprietary software that is never updated and likely contains many security issues
  • in some hosting environments a KVM must be manually attached and is charged at an hourly rate. That means you end up paying the remote hands for attaching the KVM, plus possibly an extra charge if you need it outside business hours and the hourly rate.

Thus, as a general rule, one wants to avoid a BMC/KVM as much as possible.

FAQ

  • How to make the early boot sshd listen on a non-standard port?

    A: If you really want to do that you can provide a /etc/sysconfig/dracut-sshd that defines SSHD_OPTS (see also).

  • Why does sshd hangs during early-boot when running dracut-sshd inside a virtual machine (VM)?

    A: Most likely the VM guest is short of entropy and thus sshd blocks during startup (without logging a warning) for an indefinite amount of time. Possible up to the systemd service restart timeout. Directing some of the VM host's entropy into the VM guest fixes this issue (cf. these comments for examples of how to do this).

  • Why do I get Permission denied (publickey) although the same authorized key works after the system is booted?

    A: This can be caused by a root account that is locked with ! instead of *. In that case it's enough to change the lock method (or set a password) and regenerate the initramfs. Background: On some systems Dracut also includes /etc/shadow which is then used by sshd. In early userspace, there is no PAM, thus sshd uses built-in code for shadow handling. In contrast to usual PAM configuration (which is used by late userspace sshd, by default), sshd itself differentiates between * and ! as invalid password field tokens. Meaning that only * allows public key authentication while ! blocks any login (see also).

  • Can I use dracut-sshd when my root account is locked?

    A: Yes, you can. However, you have to make sure that your account isn't locked with a ! in /etc/shadow. If it is locked like that, you have to lock it differently, e.g. via usermod -p '*' root or simply set a strong password for the root user, followed by dracut -f. See also the previous question for additional details.

  • Does dracut-sshd only work with networkd?

    A: No, it doesn't. Dracut-sshd is network service agnostic. It just requires the network being online during early boot. Depending on the distribution, there might be different alternatives available for bringing network interfaces up early, such as Systemd's networkd, legacy network scripts, NetworkManager etc. A given distribution and release might support one of those or many, and default to one of them when the network dracut module is included. Besides selecting a specific dracut network module, there are also dracut cmdline parameters for configuring network options and addresses. Depending on your concrete network setup and distribution, a certain network module might be more suitable than another. In general, it isn't an issue to use one network service during early boot and another for late boot (e.g. networkd and NetworkManager). The same goes for configurations, e.g. perhaps for early boot a simple DHCP setups makes most sense while in late boot you have a more complicated network configuration.

  • How do I make it work on Ubuntu 20.04?

    A: There are some pitfalls on Ubuntu. Firstly, dracut isn't installed by default (fix: apt install dracut-core dracut-network). Secondly, dracut isn't a first class citizen on Ubuntu (i.e. it's only included in the universe repository, not in the main repository). As a result, the default dracut initramfs filename doesn't match what Ubuntu uses in its Grub configuration. Thus, you have to explicitly specify the right one (i.e. /boot/initrd.img-$(uname -r)) in the dracut and lsinitrd commands.

  • How do I debug dracut-sshd issues in the early boot environment?

    A: You start by dropping into the dracut emergency shell and looking at the journal and status of the involved services. For example, via systemctl status sshd.service, journalctl -u sshd etc. You drop into the emergency shell by adding rd.break (and possibly rd.shell) to kernel parameter command-line. Of course, you need some kind of console access when doing such debugging. Using a virtual machine usually is sufficient to reproduce issues which simplifies things.

Related Work

There is the unmaintained (since 2019 or earlier) dracut-crypt-ssh module which aimed to provide SSH access for remotely unlocking an encrypted LUKS volume. Main differences to dracut-sshd:

  • uses Dropbear instead of OpenSSH sshd (cf. the Space Overhead Section for the implications)
  • doesn't use systemd for starting/stopping the Dropbear daemon
  • generates a new set of host keys, by default
  • listens on a non-standard port for ssh, by default
  • arguably more complex than dracut-sshd - certainly more lines of code and some options
  • comes with an unlock command that is superfluous in the presence of systemd-tty-ask-password-agent - and it's kind of dangerous to use, e.g. when the password prompt times out the password is echoed to the console

In 2017, a dracut-crypt-ssh pull request added support for optionally using OpenSSH's sshd instead of Dropbear, without changing the other differences. It was closed without being merged in 2021.

There are also some other dracut modules that use Dropbear: mk-fg/dracut-crypt-sshd which was marked deprecated in 2016 in favour of the above dracut-crypt-ssh. It uses Dropbear and some console hacks instead of systemd-tty-ask-password-agent. mdcurtis/dracut-earlyssh is a fork mk-fg/dracut-crypt-sshd. The main difference is that it also suppports RHEL 6 (which features a quite different version of dracut). xenoson/dracut-earlyssh is a fork of mdcurtis/dracut-earlyssh. It has RHEL 6 support removed and some questionable helpers removed. It creates a systemd unit file for Dropbear although it still explicitly starts/stops it via hook files instead of making use of the systemd dependency features.

The ArchWiki dm-crypt page lists two initramfs hooks for remote access. Both don't use Dracut nor systemd, though. Also, they use Dropbear and Tinyssh as ssh daemon.

Clevis, an automatic decryption framework, has some LUKS unlocking and Dracut support. Looking at its documentation, when it comes to automatic LUKS unlocking, the LUKS passphrase is stored encrypted in the LUKS header. Clevis then decrypts it using an external service/hardware (e.g. a Tang server or a TPM module).

Similar to Clevis, Mandos also implements a framework for unattended LUKS unlocking. Unlike Clevis, it primarily targets Debian and doesn't support TPM. That means for unlocking the Mandos client fetches the asymmetrically encrypted LUKS password from a Mandos server.

With version 248 (i.e. available since early 2021 or so), systemd integrated some automatic LUKS2 volume unlocking features. Similar to Clevis it supports TPM2 modules. In addition, it also supports smart cards and FIDO2/hmac-secret devices. At least some of those FIDO2 devices seem to support non-interactive HMAC computation and thus allow to auto-unlock LUKS volumes as long as the enrolled FIDO2 device is connected.

If your threat model goes beyond what is described in the Host Keys Section, you have to look into authenticated boot and disk encryption.

Although enterprise motherboard and server vendors often integrate unpleasant BMCs (cf. the Hardware Alternatives Section), a hardware solution for remote access to early boot doesn't have to be awful. For example, there is the open and DIY Pi-KVM project which looks quite promising.

Related Fedora ticket: Bug 524727 - Dracut + encrypted root + networking (2009)

Tested Environments

  • Fedora Silverblue 33
  • Fedora 27 to 38
  • CentOS 7, 8
  • CentOS Stream 9 (by a contributor)
  • RHEL 8 beta 1
  • Rocky Linux 8.8, 9 (by a contributor)
  • Gentoo (by a contributor)
  • SUSE (by a contributor)
  • openSUSE Leap 15.5
  • Arch (by a contributor)
  • Ubuntu 20.04 LTS
  • Debian 12 (by a contributor)

Packages

dracut-sshd's People

Contributors

53c70r avatar aafeijoo-suse avatar cryptomilk avatar ellisonpatterson avatar geertsky avatar gsauthof avatar ibukanov avatar jm1 avatar lapseofreason avatar lasereyess avatar purpleidea avatar robertobochet avatar suhancz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dracut-sshd's Issues

Doesn't seem to work on Fedora 36 beta (Kinoite)

Things were fine on 35 Kinoite. I did the usual:

  • added the COPR
  • added network module to dracut.conf.d
  • did the overlay:
rpm-ostree install dracut-sshd dracut-network
rpm-ostree kargs --append-if-missing=rd.neednet=1 --append-if-missing=ip=dhcp
rpm-ostree initramfs --enable

network is going up on boot and I can ping the machine, but ssh is not running. i've tried entering rd.break emergency shell and systemctl doesn't know anything about ssh-related services and journalctl is also blank.

doesn't seem like sshd is even in the initramfs:

[root@homepc dracut.conf.d]# lsinitrd /boot/ostree/fedora-abe0ad1377294aefb54bcb7d6b0b48bb800574184999dd8c01e6ce8615f4071e/initramfs-5.17.3-302.fc36.x86_64.img  | grep ssh
-rwxr-xr-x   1 root     root       460064 Jan  1  1970 usr/lib64/libssh.so.4.8.7
lrwxrwxrwx   1 root     root           27 Jan  1  1970 usr/lib64/libssh.so.4 -> ../../lib64/libssh.so.4.8.7

how to proceed to debug this further? thanks in advance.

Centos 8 : error loading shared libraries

Hi,

I'm trying dracut-sshd on Centos 8, and sshd will not start.
I have the logs : ssh: error while loading shared libraries: libfipscheck.so.1 (and the same with libutil after I fix fipscheck)

Maybe related the sshd host version ? I have the OpenSSH_8.0p1, OpenSSL 1.1.1c FIPS 28 May 2019

I fix it by adding the lib into the dracut module install script :

cp /usr/lib64/libfipscheck.so.1 $initdir/usr/lib64/libfipscheck.so.1
cp /usr/lib64/libfipscheck.so.1.2.1 $initdir/usr/lib64/libfipscheck.so.1.2.1
cp /usr/lib64/libutil.so.1 $initdir/usr/lib64/libutil.so.1
cp /usr/lib64/libutil-2.28.so $initdir/usr/lib64/libutil-2.28.so 

But how dracut can install dependencies automatically ?

Aligning with dracut-crypt-ssh?

Inspired by this thread: dracut-crypt-ssh/dracut-crypt-ssh#43

What do the dracut-sshd maintainers think of this? The main difference I see off the bat, which I require, is the ability to use it on systems without systemD. Perhaps work can be deduplicated? What would the challenges be? I notice that more people are watching & have stared dracut-crypt-ssh than dracut-sshd on GitHub - despite not being updated for years.

Thanks for your great work!

Permission denied (publickey)

Hi, when I attempt to ssh to unlock my system, I get Permission denied (publickey)

But once the system in booted I am able to ssh in with the same key. I was concerned that maybe my authorized_keys file wasn't getting loaded properly but

# lsinitrd | grep authorized_keys                                        
-rw-------   1 root     root          554 Mar 16 11:15 root/.ssh/authorized_keys

would lead me to believe that that's not the problem.

Can't enable COPR repo on ARM devices (aarch64)

I recently installed Fedora Server 33 on a Raspberry Pi and noticed that the repo can't be enabled on it. The reason seems to be that DNF doesn't check the x86_64 subrepo for noarch packages and thus disallows enabling the repository stating that there are no builds available.

A workaround for those having the same issue would be as follows: Download the repo file manually and edit the base_url attribute to exclude the $basearch variable.

E. g.
baseurl=https://download.copr.fedorainfracloud.org/results/gsauthof/dracut-sshd/fedora-$releasever-$basearch/
should be changed to
baseurl=https://download.copr.fedorainfracloud.org/results/gsauthof/dracut-sshd/fedora-$releasever-x86_64/

Better way to detect systemd-network presence

The depends function checks for presence of systemd-networkd using:

 -L /etc/systemd/system/multi-user.target.wants/systemd-networkd.service

This misses the case when systemd-networkd is enabled via drop-in config file in multi-user.target.d or via a systemd generator with a link under /run/systemd.

The code should instead use systemctl -q is-enabled systemd-networkd or perhaps just check for the presence of systemd-networkd binary.

Does not work with RHEL8

Just came across this project while migrating from dracut-crypt-ssh on Centos 7 to RHEL8.

This project does not seem to work with RHEL8.

Upon booting, the console requests the passphrase be entered PRIOR to ssh being started.

I tried to debug this some by looking at the debug logs and such...

I believe the issue is the following two lines add:

# required on Ubuntu 20.04
After=systemd-tmpfiles-setup.service

I commented out those 2 lines and it now works. Is it possible that by adding an 'After' for a target that does not exist on RHEL8, you have delayed the start of the sshd.service?

Support Request: Debugging Network Issue

Sorry to put a help request here, but I don't know where else I can put it.

I'm testing dracut-sshd on a Fedora Server 38 + LUKS installation in Gnome Boxes. But when in LUKS dialog, I cannot connect to the sshd of the VM saying "No route to host":

$ ssh 192.168.122.48
ssh: connect to host 192.168.122.48 port 22: No route to host

Seems the network is not up, although networkd service seems to be running when I reach the LUKS passphrase dialog
image

Please advice on how to track down such issue?

Installation Details

  • Networking on the box seem to work properly (i.e. DHCP correctly pic up IP and I can ssh to it) after disk unlock and boot.
  • The network interface is up with DHCP setup:
    # nmcli connection show
    NAME    UUID                                  TYPE      DEVICE 
    enp1s0  df5d3f27-7ad5-398b-9465-3b1582790893  ethernet  enp1s0 
    lo      2b2e90b0-a22c-4f9c-9384-908fd1e38182  loopback  lo
    
  • I've setup based on README.md with both COPR setup and the 2 files (/etc/systemd/network/20-wired.network, /etc/dracut.conf.d/90-networkd.conf) copied from example.
  • The dracut-sshd module is correctly registered:
    # dracut --list-modules | grep sshd
    sshd
    
  • I've verified, with lsinitrd | grep 'authorized\|bin/sshd\|network/20' that the files etc/systemd/network/20-wired.network and root/.ssh/authorized_keys are in the initrd file.
  • As the example, the interface is setup to DHCP
    # lsinitrd -f etc/systemd/network/20-wired.network
    
    # Generic networkd configuration
    # copy to /etc/systemd/network/20-wired.network
    
    [Match]
    Name=e*
    
    [Network]
    DHCP=ipv4
    

Issue changing default ssh port

I saw the FAQ mentioning creating SSHD_OPTS line in /etc/sysconfig/dracut-sshd but it is still not working for me so I imagine I have a format error. What is the proper format? I currently have this single line: SSHD_OPTS -p 45000. But it still connects on port 22

RFC: do not include all of /etc/systemd/network/* when using systemd-networkd

This may seem like a configuration difference but there are very real reasons not to include these files:

  1. Some devices (tun, tap, wireguard) can have private information included in the configurations. Leaking this information in the initramfs may not be ideal at best, and a security issue at worst.
  2. Identical network configurations during boot and a running system are not always desired or even practical/possible.

I believe the above reasons are why not even dracut's built-in systemd-networkd brings over the configurations to the initramfs. Instead they give the option of using install_items=/install_optional_items= to include what you need. Another alternative would be to glob something like 99-dracut-*.{network,netdev,link} so the user can explicitly say they want those files in their initramfs.

Willing to make a PR for this if you think it's a good idea.

Rocky Linux 8.5: seems to be loading sshd too late to enter LUKS password

I am debugging this on a VM using Rocky Linux 8.5. It was installed using autopart --encrypt, which I understand means that all partitions are encrypted.

When I boot the VM and get to the LUKS password prompt the network is running (there is a console message indicating the network is up and I can ping the VM), but ssh does not seem to be running (port22: connection refused when I try to ssh to it). The network is started using kernel command line parameters (rd.neednet=1 ip=dhcp).

I added rd.break=pre-mount to help debug. The password prompt comes up before the exit into the shell. If I enter the password, booting continues and it exits at the pre-mount stage. At that stage root is not mounted (ls / shows what seems to be the initrd and the first line of the mount command says none at / type rootfs). There is also nothing in boot. I tried rd.break=pre-trigger and rd.break=initqueue. They are before the LUKS password request and networking is not started.

I looked at the order of the modules, and sshd seems to be started well before the modules that deal with encryption and mounting.

The password prompt gives the uuid of the root partition. I am using UEFI boot, and /boot and /boot/efi are on partitions that are not encrypted.

I saw the issue about lack of randomness, but this VM already gets /dev/urandom from the host. The host (also Rocky Linux 8.5) is physical and has plenty of stuff running on it so I don't think that is the issue. Also, typing random characters into the prompt does not cause sshd to start.

It seems that the sshd is not starting early enough in the boot process. Any thoughts on how to fix or debug this or what the problem is?

COPR `epel-9-*`

Hi,

is it possible to add a COPR repo for epel-9-x86_64 and epel-9-aarch64?

Thanks!

Passphrase not working, although working with normal SSH

@gsauthof I did all the correct procedures, and I verified for ssh auth keys presence through lsinitrd | grep 'authorized\|bin/sshd\|network/20' however using my passphrase doesn't work in machine boot, yet works when I normally SSH to the machine after it completely boots.

Fedora 36 64bit with no customization or weird configs whatsoever.

No idea how to debug!

Fedora 30 build

Hi @gsauthof,

could you enable Fedora 30 build on Copr?
Fedora 29 package works fine on Fedora 30, so I would say just tick a box and maybe do a new tag without changes should be enough

Thanks
Etienne

(document) way to configure port

I like to use a separate key for the dracut-sshd, because I don't like to have my unencrypted private SSH key on the disk.
(it's still safer than an unencrypted disk, but significant drawback to a fulldisk encryption)

But I don't like to have SSH daemons with different keys on the same port. Else SSH clients will complain. So I need to configure another port for the dracut-sshd.

Sadly I couldn't find any documentation how to configure the port.
Can I simply create an /etc/ssh/dracut_sshd_config?

(like https://github.com/dracut-crypt-ssh/dracut-crypt-ssh does it)

non-interactive device unlock/ansible

Is it possible to unlock the device in an non-interactive way?

I am trying to execute a raw command from ansible but I cannot find out which command to provide.

Any ideas how can I unlock the device in this case?

OpenSUSE Leap 15.3 - can't connect to host

Hi there,

I had this setup working previously on a host with OpenSUSE Tumbleweed. I just needed to setup another computer with OpenSUSE Leap 15.3 and followed the very same instructions. I copied the files to /usr/lib/dracut/modules.d, in /etc/systemd/network and in /etc/dracut.conf.d. Ran sudo zypper install systemd-network and sudo dracut -f -vcs. I have the authorized_keys file in all 3 folders mentioned on the page.

After rebooting I only get:

ssh: connect to host 192.168.178.100 port 22: Connection refused

/var/sshd doesn't get created on Ubuntu 20.04

Hey @gsauthof ,

I'm trying to get this to work on Ubuntu 20.04, and ssh server keep failing to start.
image
If I create a folder myself in /var/sshd with 0755, it'll start right away, but I have to make that change manually.

Any idea how could I solve this?

Thanks,
Mark

sshd service first start fails

Hello,

I have an issue on my centos 8 VM (I'm not using networkd - it is not available in centos 8).

During the sysinit, sshd fails to start the first time, it works afterwards, I have no relevant logs from journald (only process exited with code 1), therefore the boot process is delayed for a minute until sshd tries to restart.

Maybe you know of this issue, if not, please could you tell me how I could get more relevant logs about why sshd fails to start ? I tried adding -d to the Exec without much success.

Thank you very much

NetworkManager Early-Boot Configuration Challenges

While dracut-sshd works, it also overrides my network configuration.

Before using dracut-sshd my network was setup with NetworkManager and there was one entry in nmcli con show for my network adapter (but I am using multiple IPs on that interface).

After installing dracut-sshd, my "real" network setup no longer works, because after booting up, the setup in 20-wired.network is active and my NetworkManager setup is not. There are also 2 entries in nmcli con show for my adapter now, but the one that was setup during the initramfs phase is active.

In my opinion the network setup for dracut should only be active until the boot process continues.

This is very puzzling to me, because dracut-sshd should not invalidate my previous network setup.

Is there anything I can do to fix this?

sshd doesn't start in Debian 10 initramfs

Hi,
I'm trying dracut-sshd on debian 10, and sshd will not start.
I can see the following in the logs :

janv. 29 20:44:09 systemd[1]: Starting OpenSSH server daemon...
janv. 29 20:44:09 sshd[1891]: Missing privilege separation directory: /run/sshd
janv. 29 20:44:09 systemd[1]: sshd.service: Main process exited, code=exited, status=255/EXCEPTION
janv. 29 20:44:09 systemd[1]: sshd.service: Failed with result 'exit-code'.
janv. 29 20:44:09 systemd[1]: Failed to start OpenSSH server daemon.

So the reason why it fails it quite obvious, bit how could I include this /run/sshd directory inside the initrd ?

TIA, kind regards.

Upgrading Fedora Version does not Work

Hi, thanks for this great module, it works very great on Fedora 30.
However, when I try to upgrade to Fedora 31 with dnf system-upgrade reboot, then I cannot log into my server any more.
One workaround is to boot the server from usb stick after the upgrade, mount the encrypted root filesystem, chown to that filesystem and then run dracut -f -kver [kernelversion].
After this procedure I can reboot the server and boot without usb stick assistance.

However, this is quite cumbersome. Does anyone have an idea of how to get dnf system-upgrade reboot to automatically execute dracut -f before it is done?

Does this module support OpenSSH Certificates?

I'm interested to allow a range of backup admins with their OpenSSH Certificates from our infrastructure. This is not stated in the README so I'm wondering, does dracut-sshd support this?

Such certificates would allow to handle the access control to initramfs rescue shell with issuing and revocation of certificates for the individuals ssh keys.

Reboot in Dracut

Hi!

Is it possible to trigger a reboot from the ssh session?

Something went wrong inserting the password and the server did not boot. systemd-tty-...password will not ask for password anymore.

I know is an edge case, but looks like I might beed to make a physical reset otherwise.

I tried reboot, but just waits.

SSHD not starting on CentOS 8 VM?

Description

I am booting a CentOS 8 via KVM / virt-manager with kernel options rd.neednet=1 ip=dhcp

Expected behavior

I can login via ssh to enter the password

Observed behavior

Connection on port 22 is refused
( implying that the network setup via dhcp works fine right? )

Additioal Information

If I add rd.break to the cmdline, enter the LUKS password using virt-manager I get dropped to the dracut rescue shell and I can connect via ssh. This is still the initramfs sshd right?

Do you have some tips how to debug this?

RFC: Use Include directive in sshd_config instead of env variables

I think something like

SyslogFacility                  AUTHPRIV
PermitRootLogin                 prohibit-password
AuthorizedKeysFile              .ssh/authorized_keys
AuthenticationMethods           publickey
UsePAM                          no
X11Forwarding                   no

AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE

Include /etc/ssh/dracut_sshd_config

Would be a nice addition since it allows you to use an sshd_config format to configure dracut's sshd explicitly. Putting $SSHD_OPTS in /etc/sysconfig/sshd seems like a compromise of allowing dracut specific options without pulling in your system's /etc/sshd_config.

Willing to make a PR for this as well.

CentOS 9

Hi there,
I love this project, it's great work!
Would it be possible to build it for CentOS Stream 9 too?

Decrypt Timeout on Arch

Greetings, I have switched from grub to systemd-boot, mkinitcpio to dracut, and am using this for unlocking machines I am not sitting in front of.

It works wonderfully except that if I do not enter the password within ~90 seconds dracut launches the emergency shell.

I see this was apparently an issue in the past on Fedora in the past and that's mentioned in the readme here, does anyone have any idea how to patch this on Arch?

systemd-networkd persists through switchroot and breaks lots of stuff

Fedora 38
systemd-networkd-253.5-1.fc38.x86_64
dracut-059-3.fc38.x86_64
dracut-sshd-0.6.5-1
NetworkManager-1.42.6-1.fc38.x86_64

If you use /etc/systemd/network/20-wired.network as suggested in the documentation it can create serious problems.

DHCP conflict, IP address doubling

  1. systemd-networkd does DHCP on the ethernet interface and allow you to ssh in to type the LUKS passphrase. Unfortunately it does DHCP with a different DUID (and possibly other parameters, not sure) where the DHCP server can too easily give it a different IP address despite the MAC address being the same. Reproduced against two different DHCP servers, Google Fiber's proprietary gateway and Open Source dnsmasq-2.89-5.fc38.x86_64. At this point I see one IPv4 and one IPv6 address on the interface during initramfs (see ip addr).
  2. But it gets worse. The ethernet interface remains active with that address into the switchroot. The OS will then likely DHCP again with the original (pre-dracut-sshd rootfs DUID). It can then be be assigned an IP address different from those assigned during initramfs because the DUID is different and/or the previous IP address is seen as active on the local network. At this point I see two IPv4 addresses and two IPv6 addresses on the interface.
  3. But it gets worse. The IPv4 and IPv6 addresses assigned during initramfs remains on the interface alongside the rootfs IPv4 and IPv6 addresses. But at a random time hours later, the initramfs IPv6 address disappears because there's no daemon managing its lease (?). Not sure why but it happens. This can too easily confuse other software and break stuff.

Other Conflicts

Because systemd-networkd did not cleanly teardown the interface prior to switchroot it creates other problems. For example my buddy has been using dracut-sshd for a few years. He had to add hacky scripts post-boot to force the persisting interface to reset before his NetworkManager adds it to a virtual bridge device, and that virtual bridge device is what runs DHCP on the LAN.

It's possible systemd-networkd could be configured to do the same as these more complicated NetworkManager scenarios. But NetworkManager is the default on many distros and we shouldn't force people to stop using it. dracut-sshd can be become nicely compatible with NetworkManager.

networkd could be mitigated

You could add a hook to tear down the ethernet interface prior to switchroot. I am not sure where or how. I confirmed manually in the rd.break shell that networkctl down DEVICENAME deactivated the interface in such a way that rootfs NetworkManager later had no trouble.

This would be an improvement but it doesn't escape the fact that it is a different DHCP client that can too easily get a different address.

NetworkManager for dracut-sshd

See #69 for the simplest way to activate NetworkManger during initramfs for dracut-sshd. It even nicely tears down the network prior to switchroot.

GPL 2 licensing

Hi Georg,

you mentioned somewhere, you would like to see that module upstream by dracut. Within README.md you mention that this work is licensed under 'GPLv3+'. Dracut is licensed under GPLv2. In this case this is a bit problematic.

May I ask you to relicense your work under 'GPLv2' to get it compatible with dracut?
(and can you please add the License file and according steps required by GPLv2 too?)

Many thanks!
Artem

/cc @rbu

SSHD failed to start when ssh host key does not exist

Issue:
sshd service failed to start if it can't find any ssh host key.

image

Context:
When installing dracut-sshd inside kickstart %post section, ssh host key is not already generated at this stage (generated at first boot).
The dracut install script (module-setup.sh) does not check if host key exist and build an initramfs image without it, resulting in shhd to not start.

Workarroud (in my case):
Pre-generate ssh host key with ssh-keygen -A before executing dracut -v -f

Enhancement:
Add a check inside module-setup.sh to ensure at least one ssh host key exist.
if not drop an error when regenerating initramfs via dracut.

This would do the job:

    install() {
    local key_prefix key_type ssh_host_key authorized_keys totalhostkey hostkeyerror  
    hostkeyerror=0
    totalhostkey=0
    key_prefix=
    if [ "$(find /etc/ssh -maxdepth 1 -name 'dracut_ssh_host_*_key')" ]; then
        key_prefix=dracut_
    fi
    for key_type in dsa ecdsa ed25519 rsa; do
        ssh_host_key=/etc/ssh/"$key_prefix"ssh_host_"$key_type"_key
        ((totalhostkey++))
        if [ -f "$ssh_host_key" ]; then
            inst_simple "$ssh_host_key".pub /etc/ssh/ssh_host_"$key_type"_key.pub
            /usr/bin/install -m 600 "$ssh_host_key" \
                    "$initdir/etc/ssh/ssh_host_${key_type}_key"
        else
            ((hostkeyerror++))
        fi
    done

    if [ "${hostkeyerror}" -eq "${totalhostkey}" ]; then
       dfatal "No ssh_host_*_key or dracut_ssh_host_*_key found in /etc/ssh directory !"
       return 1
    fi

Wrong URL for CentOS 8 repo

In https://copr.fedorainfracloud.org/coprs/gsauthof/dracut-sshd/repo/epel-8/gsauthof-dracut-sshd-epel-8.repo linked on https://copr.fedorainfracloud.org/coprs/gsauthof/dracut-sshd/

baseurl=https://copr-be.cloud.fedoraproject.org/results/gsauthof/dracut-sshd/rhelbeta-8-$basearch/

should be

baseurl=https://copr-be.cloud.fedoraproject.org/results/gsauthof/dracut-sshd/epel-8-$basearch/

After changing that dnf install dracut-sshd succeeded.

Complete steps to install on CentOS 8:

wget -O /etc/yum.repos.d/dracut-sshd.repo https://copr.fedorainfracloud.org/coprs/gsauthof/dracut-sshd/repo/epel-8/gsauthof-dracut-sshd-epel-8.repo
sed -i 's:rhelbeta:epel:g' /etc/yum.repos.d/dracut-sshd.repo
dnf install -y dracut-sshd

tumbleweed not working

Installed on a fresh server install of tumbleweed.

Steps

  • Install dracut-sshd
  • run dracut -f -v
  • reboot

Unable to SSH to machine, ran NMAP scan nothing open.

Alternate steps

  • Install dracut-sshd
  • use the two configs from example folder on repo
  • add additional params to grub
  • regenerate grub config
  • run dracut -f -v
  • reboot

Same response and not seeing any errors in logs :/

root user must be unlocked (* not ! in /etc/shadow)

Small PSA, just did a new Fedora 31 install this morning, and since pretty recently dracut now copy the root:... line from system /etc/shadow to etc/shadow in the initramfs, before there was no etc/shadow in initramfs

sshd is launched with UsePAM no in the initramfs, so we need root not to be locked, ie you need
root:*:18343:0:99999:7:::
not
root:!:18343:0:99999:7:::

In my kickstart i was locking root using usermod -p '!' root, which allow me to login to the regular Fedora install, but not the initramfs sshd. It should have been usermod -p '*' root

Quick check:

grep '^root:!' /etc/shadow -q && echo "you need to unlock your root user" || echo "ok"

Rocky Linux 9, Permission denied (publickey)

Hi trying to set dracut-sshd to unlock my home server remotely and I get the Permision denied (publickey) error.

I've tried to change the root accound unlocking method following using sudo usermod -p '*' root and regenerating the initramfs with sudo dracut -f -v

The auth key file is the same as the one I use to unlock my account after unlocking so it should work.

I don't get what I'm doing wrong.

No SSH host keys on fresh install

Hiya, I've just been through a fresh Arch install on a remote host, and noticed that the SSH host keys won't be generated until after sshd.service - and thus, sshdgenkeys.service - is run for the first time. systemd won't run inside the typical arch-chroot part of the install process, which is all you have until you unlock the drives and boot Linux for the first time (not possible without the host keys).

Given that sshdgenkeys.service is basically just a thin wrapper around ssh-keygen -A, could we just create the missing host keys with ssh-keygen -A instead of erroring out? Or perhaps just a text fix to essentially say "run ssh-keygen -A"?

It's not a huge issue, just a QoL change that I think would be nice. :)

Ubuntu 20.04 - ssh Connection timed out - not working

Hello,

After going through all the steps, I can't connect to unlock the luks after reboot.

SERVER
Please enter passphrase for disk XXX (sda6_crypt):

CLIENT
ssh -vv [email protected]
OpenSSH_6.8p1-hpn14v6, OpenSSL 1.0.2h-fips 3 May 2016
debug1: Reading configuration data /root/.ssh/config
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.10.77 [192.168.10.77] port 22.
debug1: connect to address 192.168.10.77 port 22: Connection timed out
ssh: connect to host 192.168.10.77 port 22: Connection timed out

All steps :
Ubuntu Desktp 20.04 clean install.

SERVER
apt remove libreoffice*
apt update
apt upgrade
apt install -y qt5-default libqt5designer5 libqt5help5 python3-psutil
python3-pyqt5 python3-pyqt5.qtsvg python3-sip qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools
apt-file base-files btrfs-progs cbm cryptsetup cryptsetup-initramfs gcc
git libblkid-dev libc6 libc6-amd64-x32-cross libc6-dev libc6-dev-i386
mc make ufw rsync lvm2
dracut dracut-network

apt clean
apt autoremove

SERVER SSH config:

vi /etc/ssh/sshd_config
PermitRootLogin yes

#as root
passwd
#change root pwd to my_new_pwd

mkdir /root/.ssh

CLIENT:
#login as root
cd ~/.ssh/
ls -la .pub
scp ~/.ssh/
.pub root@SERVER:/root/.ssh/
#end

SERVER:
#as root
cd /root/.ssh
cat *.pub >>authorized_keys
rm -f *.pub
cat authorized_keys

SERVER:
cd /opt
git clone https://github.com/gsauthof/dracut-ssh
cd dracut-ssh
cp -ri 46sshd /usr/lib/dracut/modules.d

vi /etc/systemd/network/20-wired.network
[Match]
Name=enp4s0

[Network]
DHCP=ipv4

vi /etc/dracut.conf.d/90-networkd.conf
install_items+=" /etc/systemd/network/20-wired.network "
add_dracutmodules+=" systemd-networkd "

vi /etc/default/grub
#modify:
GRUB_CMDLINE_LINUX_DEFAULT="quiet rd.neednet=1 ip=dhcp"

#then
update-grub

rm /root/dracut.log
dracut -f -v |tee -a /root/dracut.log

grep -i sshd /root/dracut.log
#sshd modue included -> OK!

reboot

What else can I do to get this up and running?
Any help appreciated.

`sshd` service continually restarts

Issue:
After entering the initramfs, it appears that the sshd service continuously restarts, even after a login has been created in that session. This can be seen starting at '00:13:18', where a previous process is busy pid 450 and doesn't shutdown due to an active session.

Journal Excerpt:

Jul 24 00:08:10 kuro-unlock systemd[1]: sshd.service: start operation timed out. Terminating.
Jul 24 00:08:10 kuro-unlock sshd[213]: Received signal 15; terminating.
Jul 24 00:08:10 kuro-unlock systemd[1]: sshd.service: Failed with result 'timeout'.
Jul 24 00:08:10 kuro-unlock systemd[1]: Failed to start OpenSSH server daemon.
Jul 24 00:08:53 kuro-unlock systemd[1]: sshd.service: Scheduled restart job, restart counter is at 1.
Jul 24 00:08:53 kuro-unlock systemd[1]: Stopped OpenSSH server daemon.
Jul 24 00:08:53 kuro-unlock systemd[1]: Starting OpenSSH server daemon...
Jul 24 00:08:53 kuro-unlock sshd[445]: Server listening on 0.0.0.0 port 22.
Jul 24 00:08:53 kuro-unlock sshd[445]: Server listening on :: port 22.
Jul 24 00:10:23 kuro-unlock systemd[1]: sshd.service: start operation timed out. Terminating.
Jul 24 00:10:23 kuro-unlock sshd[445]: Received signal 15; terminating.
Jul 24 00:10:23 kuro-unlock systemd[1]: sshd.service: Failed with result 'timeout'.
Jul 24 00:10:23 kuro-unlock systemd[1]: Failed to start OpenSSH server daemon.
Jul 24 00:11:05 kuro-unlock systemd[1]: sshd.service: Scheduled restart job, restart counter is at 2.
Jul 24 00:11:05 kuro-unlock systemd[1]: Stopped OpenSSH server daemon.
Jul 24 00:11:05 kuro-unlock systemd[1]: Starting OpenSSH server daemon...
Jul 24 00:11:05 kuro-unlock sshd[447]: Server listening on 0.0.0.0 port 22.
Jul 24 00:11:05 kuro-unlock sshd[447]: Server listening on :: port 22.
Jul 24 00:12:35 kuro-unlock systemd[1]: sshd.service: start operation timed out. Terminating.
Jul 24 00:12:35 kuro-unlock sshd[447]: Received signal 15; terminating.
Jul 24 00:12:35 kuro-unlock systemd[1]: sshd.service: Failed with result 'timeout'.
Jul 24 00:12:35 kuro-unlock systemd[1]: Failed to start OpenSSH server daemon.
Jul 24 00:13:18 kuro-unlock systemd[1]: sshd.service: Scheduled restart job, restart counter is at 3.
Jul 24 00:13:18 kuro-unlock systemd[1]: Stopped OpenSSH server daemon.
Jul 24 00:13:18 kuro-unlock systemd[1]: sshd.service: Found left-over process 449 (sshd) in control group while starting unit. Ignoring.
Jul 24 00:13:18 kuro-unlock systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
Jul 24 00:13:18 kuro-unlock systemd[1]: sshd.service: Found left-over process 450 (sshd) in control group while starting unit. Ignoring.
Jul 24 00:13:18 kuro-unlock systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
Jul 24 00:13:18 kuro-unlock systemd[1]: Starting OpenSSH server daemon...
Jul 24 00:13:18 kuro-unlock sshd[451]: Server listening on 0.0.0.0 port 22.
Jul 24 00:13:18 kuro-unlock sshd[451]: Server listening on :: port 22.
Jul 24 00:13:59 kuro-unlock sshd[449]: Connection closed by authenticating user root xxx.xxx.xxx.xxx port 50816 [preauth]
Jul 24 00:14:23 kuro-unlock sshd[452]: Accepted publickey for root from xxx.xxx.xxx.xxx port 51780 ssh2: RSA SHA256:<key-fingerprint-here>
Jul 24 00:14:48 kuro-unlock systemd[1]: sshd.service: start operation timed out. Terminating.
Jul 24 00:14:48 kuro-unlock sshd[451]: Received signal 15; terminating.
Jul 24 00:14:48 kuro-unlock systemd[1]: sshd.service: Failed with result 'timeout'.
Jul 24 00:14:48 kuro-unlock systemd[1]: Failed to start OpenSSH server daemon.
Jul 24 00:15:30 kuro-unlock systemd[1]: sshd.service: Scheduled restart job, restart counter is at 4.
Jul 24 00:15:30 kuro-unlock systemd[1]: Stopped OpenSSH server daemon.
Jul 24 00:15:30 kuro-unlock systemd[1]: sshd.service: Found left-over process 452 (sshd) in control group while starting unit. Ignoring.
Jul 24 00:15:30 kuro-unlock systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
Jul 24 00:15:30 kuro-unlock systemd[1]: sshd.service: Found left-over process 454 (sh) in control group while starting unit. Ignoring.

Integrate into upstream dracut

@danimo what would be needed to get this upstream?

Currently OpenSSH is the only ssh server with FIPS support. For a smaller solution we would need to build something using libssh.

Getting permission denied errors for systemd-networkd on boot

Ahoi,
pretty happy to find this dracut module. Sadly I can't get it to work.
I've already jumped through a few hoops with systemd-networkd but that seems to work now.

$ networkctl
IDX LINK   TYPE     OPERATIONAL SETUP
  1 lo     loopback carrier     unmanaged
  2 enp2s0 ether    routable    configured
  3 enp3s0 ether    no-carrier  configuring
$ cat /etc/systemd/network/20-enp2s0.network
[Match]
Name=enp2s0
MACAddress=ff:00:bb:aa:rr:01

[Network]
DHCP=true
MulticastDNS=resolve
DNSSEC=allow-downgrade
$ cat /etc/systemd/network/20-enp3s0.network
[Match]
Name=enp3s0
MACAddress=ff:00:bb:aa:rr:02

[Network]
DHCP=true
MulticastDNS=resolve
DNSSEC=allow-downgrade
$ dns info dsracut-sshd
Installed Packages
Name      : dracut-sshd
Version   : 0.6.2
Release   : 1.el8
From repo : copr:copr.fedorainfracloud.org:gsauthof:dracut-sshd
$ cat /etc/centos-release
CentOS Linux release 8.2.2004 (Core)
$ cat /etc/dracut.conf.d/90-networkd.conf
install_items+=" /etc/systemd/network/20-enp2s0.network /etc/systemd/network/20-enp3s0.network "
add_dracutmodules+=" systemd-networkd "

When I reboot the system I get the following error before the password prompt:

[FAILED] Failed to start Network Service.

After booting journalctl has the following entries:

systemd[574]: systemd-networkd.service: Failed to execute command: Permission denied
systemd[574]: systemd-networkd.service: Failed at step EXEC spawning /usr/lib/systemd/systemd-networkd: Permission denied

I'm not sure what the issue is. I got a similar problem earlier when I had no read rights to my *.network files but I fixed that and regenerated the initrd.

OpenSSH service waiting for timeout

After I unlock my rootfs with systemd-tty-ask-password I can see in tty

Starting OpenSSH service and it waits until timeout. After 90 s it timeouts, prints

[FAILED] Failed to start OpenSSH server daemon.
See 'systemctl status sshd.service' for details.

and proceeds to boot normally.

I'm confused by this OpenSSH server service which happens after I already logged in via ssh and unlocked rootfs.

Submit package to Fedora

I've got some requests for getting dracut into the Fedora repository.

Status quo: there is a Copr repository that also provides Fedora packages (cf. link in the README).

Of course, having the package available in the Fedora repository makes sense as this simplifies the deployment of dracut-sshd.

There is also the idea of upstreaming dracut-sshd (cf. issue #8 ), but this likely will take some time as nobody is currently driving this effort.

For an approved Fedora packager, preparing a Fedora package review submission shouldn't take too much time. It basically involves:

  • replacing rpkg stuff from the current SPEC file
  • possibly offering a review swap on the Fedora devel mailing list

Thus, it's considerably less effort than the upstreaming and thus still worth it even if the upstreaming effort continues at some point.

Deal with travis-ci.org to tavis-ci.com transition

Travis-CI announced it some time ago and dot org page currently reads:

Please be aware travis-ci.org will be shutting down in several weeks, with all accounts migrating to travis-ci.com. Please stay tuned here for more information.

Currently, I see the following issues with the migration:

  • integration with travis-ci.com would require me to grant Travis-CI write-access to all my Github repositories - which I'm not comfortable with to do: 'This application will be able to read and write all public and private repository data.'
  • open source projects start with some free credits with the new Travis-CI service; and there is some hand-wavy language suggesting that some open source projects may request additional credits once they run out via some unspecified process. Which sound quite tedious to me.

Thus, all this hustle might require switching to another CI service. Suggestions for an alternative service are welcome!

Besides being free for open source projects, a big requirement is nested virtualization support. Without that the dracut-sshd jobs run very slow and likely hit standard CI usage limits. For Travis-CI it took years to provide job runners that support nested virtualization. Last time I checked, e.g. Github Actions didn't support it and had no concrete plans to add it.

Remote late boot LUKS unlocking

I've been trying to get this to work on my Centos installation in order to unlock the encrypted hard-drive. It seems that the network and SSH service is enabled on startup, but for some reason the connection is refused. It might be a firewall issue, but I don't know how to check that.

Some other system information for easier search: Ethernet port is enp2s0, the ethernet driver is manually installed.

Here is the message log of the boot up:
https://gist.github.com/LecrisUT/6c9f75467ffce10ced7735b4ef8ad3d0

SSH functionality, log into a LUKS encrypted CentOS 8 is not longer available after the package update

Currently, no SSH connection can be established to start an encrypted CentOS. Since an update of the dracut-sshd package, the following hook doesn't seem to work with a sudo dracut -f:

Expected behaviour/output:

# Created symlink /var/tmp/dracut.6lfHIS/initramfs/etc/systemd/system/sysinit.target.wants/sshd.service -> /usr/lib/systemd/system/sshd.service.

Since the dracut-sshd update I miss this information.

I played with different cases within a virtual machine and a fresh installed and updated CentOS.

$ uname -a
Linux VM-X-XXXX 4.18.0-193.28.1.el8_2.x86_64 #1 SMP Thu Oct 22 00:20:22 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Finally I could find out:

It runs with dracut-sshd version 0.5.1-2 (and doesn't run with 0.6.2-1):

$ yum list dracut-sshd
...
Installierte Pakete
dracut-sshd.noarch     0.5.1-2.el8     @copr:copr.fedorainfracloud.org:gsauthof:dracut-sshd
Verfügbare Pakete
dracut-sshd.noarch     0.6.2-1.el8     copr:copr.fedorainfracloud.org:gsauthof:dracut-sshd 
dracut-sshd.src        0.6.2-1.el8     copr:copr.fedorainfracloud.org:gsauthof:dracut-sshd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.