Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:ccgx
dracut-crypt-ssh
dracut-crypt-ssh-1.0.7+20181029.2204f72.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File dracut-crypt-ssh-1.0.7+20181029.2204f72.obscpio of Package dracut-crypt-ssh
07070100000000000081A4000003E800000064000000015BD6D715000046AC000000000000000000000000000000000000003000000000dracut-crypt-ssh-1.0.7+20181029.2204f72/COPYING GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. 07070100000001000081A4000003E800000064000000015BD6D715000001FD000000000000000000000000000000000000003200000000dracut-crypt-ssh-1.0.7+20181029.2204f72/COPYRIGHTThis project was originally named "dracut-crypt-sshd" and "dracut-earlyssh" before it became "dracut-crypt-ssh". It was licensed under version 2.0 of the WTFPL <http://www.wtfpl.net/txt/copying/>. The original copyright statement reads as follows: Copyright (C) 2012 Mike Kazantsev <mk.fraggod@gmail.com> The following contributors agreed to change the license to GPLv2. Michael Curtis <michael@moltenmercury.org> Maciej Żenczykowski <zenczykowski@gmail.com> Artem Sidorenko <artem@2realities.com> 07070100000002000081A4000003E800000064000000015BD6D7150000027C000000000000000000000000000000000000003100000000dracut-crypt-ssh-1.0.7+20181029.2204f72/Makefileinclude config.mk export DESTDIR= export MODULEDIR=${DESTDIR}$(DRACUT_MODULEDIR) ifeq ($(NEED_CRYPTSETTLE),1) SUBDIRS=modules/60crypt-ssh modules/cryptsettle-patch else SUBDIRS=modules/60crypt-ssh endif .PHONY: install all clean dist $(SUBDIRS) all: $(SUBDIRS) install: $(SUBDIRS) mkdir -p $(DESTDIR)/etc/dracut.conf.d/ cp crypt-ssh.conf $(DESTDIR)/etc/dracut.conf.d/ clean: $(SUBDIRS) rm -f dracut-crypt-ssh-*gz config.mk $(SUBDIRS): $(MAKE) -C $@ $(MAKECMDGOALS) DISTNAME=dracut-crypt-ssh-$(shell git describe --tags | sed s:v::) dist: git archive --format=tar --prefix=$(DISTNAME)/ HEAD | gzip -9 > $(DISTNAME).tar.gz 07070100000003000081A4000003E800000064000000015BD6D71500003365000000000000000000000000000000000000003200000000dracut-crypt-ssh-1.0.7+20181029.2204f72/README.mddracut-crypt-ssh ---------------- # 1. Introduction The crypt-ssh dracut module allows remote unlocking of systems with full disk encryption via ssh. There are a number of reasons why you would want to do this: 1. It provides a way of entering encryption keys for a number of servers without console switching 2. It allows booting of remote or co-located encrypted servers without console access Users are strictly authenticated using their SSH public keys. These can be either: `/root/.ssh/authorized_keys` or a custom file (`dropbear_acl` option). Depending on your environment, it may make sense to make the preboot authorized_keys file different from the normal one. Plain text password authentication and port forwarding are disabled. # 2. Installation We recommend installation via packages, or build manually if unavailable. You are encouraged to get in contact with us via [GitHub issues](https://github.com/dracut-crypt-ssh/dracut-crypt-ssh/issues) if you are able to provide packages for other distributions. ## 2.1. Installation from packages on Fedora/RHEL/CentOS We currently provide packages for RHEL+CentOS 7 as well as Fedora 22+ via a [COPR repository](https://copr.fedorainfracloud.org/coprs/rbu/dracut-crypt-ssh/). Installation via dnf (Fedora): # dnf copr enable rbu/dracut-crypt-ssh # dnf install dracut-crypt-ssh Installation via yum (CentOS 7): # yum install epel-release # wget -O /etc/yum.repos.d/rbu-dracut-crypt-ssh-epel-7.repo https://copr.fedorainfracloud.org/coprs/rbu/dracut-crypt-ssh/repo/epel-7/rbu-dracut-crypt-ssh-epel-7.repo # yum install dracut-crypt-ssh ## 2.2. Installation from sources on Fedora/RHEL/CentOS Install build dependencies (example commands for RPM systems). When building on RHEL, be sure to enable EPEL (`yum install epel-release`). # yum install dropbear dracut dracut-network openssh # yum install libblkid-devel gcc Retrieve a copy the source and build: $ git clone https://github.com/dracut-crypt-ssh/dracut-crypt-ssh.git $ cd dracut-crypt-ssh $ ./configure $ make $ sudo make install ## 2.3. Installation on other distributions - Gentoo: available in Portage, just `emerge sys-kernel/dracut-crypt-ssh`. - [Arch Linux](https://aur.archlinux.org/packages/dracut-crypt-ssh/), [Arch Linux Git](https://aur.archlinux.org/packages/dracut-crypt-ssh-git/) # 3. Usage ## 3.1. Building the initramfs After the first installation and every time you update the `dracut-crypt-ssh` configuration, it is required to rebuild the initramfs: # dracut --force ## 3.2 Enable network access during boot Since you need network access before booting from the root partition, you need to configure this via GRUB, if you have not done so before. The minimal change is enabling DHCP. Edit the `/etc/default/grub` file and append to the end of the `GRUB_CMDLINE_LINUX`: /etc/default/grub: ... GRUB_CMDLINE_LINUX="... rd.neednet=1 ip=dhcp" ... Afterwards, regenerate your GRUB config: # grub2-mkconfig --output /etc/grub2.cfg For a static network configuration, use something along the lines of GRUB_CMDLINE_LINUX="... rd.neednet=1 ip=192.168.0.100::192.168.0.1:255.255.255.0:centos:enp0s8:off" Refer to the [network documentation of dracut](https://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html#_network) for more options (`man dracut.cmdline`). ## 3.3. Unlocking the volumes interactively When rebooting the system, dropbear sshd is started by the initramfs. You should be able to login and unlock the volumes: % ssh -p 222 root@192.168.0.100 # console_peek # to see what's on the console # console_auth # asks you for the passphrase and sends it to console Passphrase: If unlocking the device succeeded, the initramfs will clean up itself and dropbear terminates itself and your connection. ## 3.4. Unlocking using the unlock command The `unlock` binary reads a passphrase from stdin, parses `/etc/crypttab` and attempts to call `cryptsetup luksOpen` on all luks-encrypted drives that don't have a keyfile, passing the passphrase that unlock got in stdin to luksOpen. What this means in practice is you can do: % ssh root@remote.server -p 222 unlock < passwordFile or: % gpg -d password.gpg | ssh root@remote.server -p 222 unlock If you want to only unlock specific drives / LUKS volumes, you can provide wildcards on the command line, e.g. % ssh root@remote.server -p 222 unlock luks-3467c luks-34c13 `unlock` will search the crypttab for mapper names (first column in `/etc/crypttab`) that start with the listed names. Volumes that match via this method may have a keyfile listed in `/etc/crypttab`, it will be assumed that you want to unlock the volume/s with an alternative key. Note that the names provided are really wildcards, and by convention/default all mappers start with luks-, so you can force `unlock` to try all drives simply by doing something like 'unlock luks-'. In all cases, `unlock` will only consider the process a success only if all eligible volumes are unlocked successfully. This means: 1. All the associated devices must be available at boot / unlock time 2. The passphrase must be accepted for all eligible volumes 3. cryptsetup luksOpen should not exit for any other reason. In short, if you have more than one volume in `/etc/crypttab`, you will need to be careful about how use this tool. If the process is successful, `unlock` will launch the script `/sbin/unlock-reap-success`. This will attempt to kill systemd-cryptsetup, and failing that, attempt to kill cryptroot-ask. On RHEL6 & 7, this aborts the builtin decrypt password request processes and allows the boot process to proceed. Note that the plymouth splash screen on RHEL6 (if you happen to be watching the console...) will still appear to ask for your password, but this is an artifact. Disable plymouth (rhgb command line) if this annoys you. You might want to limit access only to the unlock binary, just add command="unlock" to your authorized_keys before the key, e.g. command="unlock" ssh-rsa ..... # 4. Configuration The configuration is stored in the crypt-ssh.conf, usually located in `/etc/dracut.conf.d/`. The following options are available (see the config file for detailed description): - `dropbear_port` (default: `222`) - port ssh daemon should listen on - `dropbear_rsa_key`, `dropbear_ecdsa_key` (default: `GENERATE`) - Source of the keys, possible options: - `SYSTEM` - copy the private keys from the encrypted system (not recommended) - `GENERATE` - generate a new keys (during the creation of initramfs) - path - key file in OpenSSH format as generared by ssh-keygen (a public file with '.pub' ending must be present too) - `dropbear_acl` (default: `/root/.ssh/authorized_keys`) - Keys which allowed to login into initramfs After any configuration change, you have to rebuild the initramfs as the configuration takes effect during the building the initramfs. ## 4.1 Generating keys for dracut-crypt-ssh (recommended) By default, dracut-crypt-ssh generates an SSH key whenever the image is built (`GENERATE`), which either creates administrative overhead or weakens the security of the SSH connection as keys will be regenerated transparently during system updates. It is highly recommended to generate SSH keys specifically for dracut-crypt-ssh and validate these keys during the initial connection. The following steps should give you an idea how to set this up. You can change the directory as you wish. Keep these SSH keys safe, but also keep in mind that they will be copied to the initramfs on the unencrypted boot partition (where they may be extracted or changed). # umask 0077 # mkdir /root/dracut-crypt-ssh-keys # ssh-keygen -t rsa -f /root/dracut-crypt-ssh-keys/ssh_dracut_rsa_key # ssh-keygen -t ecdsa -f /root/dracut-crypt-ssh-keys/ssh_dracut_ecdsa_key Point to these keys in the configuration `/etc/dracut.conf.d/crypt-ssh.conf`: dropbear_rsa_key="/root/dracut-crypt-ssh-keys/ssh_dracut_rsa_key" dropbear_ecdsa_key="/root/dracut-crypt-ssh-keys/ssh_dracut_ecdsa_key" Remember regenerate the initramfs after this step: # dracut --force # 5. Troubleshooting and Debugging If things don't work as expected, there are a few ways to find out what is going, get help or report an issue. ## 5.1 Ensure disk decryption works With or without crypt-ssh installed, dracut should always prompt for a LUKS password and boot properly when the password is entered. If booting with an interactive password does not work, you need to fix that first: Ensure that the LUKS UUID configured in GRUB and the crypttab in the initramfs are up to date and all modules needed to mount the root filesystem are present in the initramfs. Refer to the [crypto LUKS documentation of dracut](https://mirrors.edge.kernel.org/pub/linux/utils/boot/dracut/dracut.html#_crypto_luks) (`man dracut.cmdline`) and your distribution documentation or help channels. ## 5.2 Ensure networking works (if you have console access) If you cannot reach the crypt-ssh host via SSH, but you still have interactive console access, you can (re)boot it with a dracut breakpoint. When GRUB presents the boot options, hit the `e` key to edit boot options and add `rd.break=pre-mount` to the boot options. Remove `rhgb` and `quiet` from the kernel command line, if they are present. Hit `Ctrl-x` to boot with the manual configuration and type your LUKS passphrase via the console. Before mounting the root filesystem, dracut will drop you into a shell. Is your network adapter present in `ip a`? If not, does your network adapter need a module (check `lsmod` and `dmesg | grep net`)? Do you have an IP address configured? Can you use `dhclient` to acquire an IP address? Is `dropbear` running (`ps aux`)? If the network adapter (module) is missing, rebuild the initramfs (`dracut -f`). If your network configuration is missing, it's probably a configuration issue. Refer to the Usage section for networking parameters. If the network comes up, but dracut does not load, that's probably a bug in dracut-crypt-ssh. [Please report it](https://github.com/dracut-crypt-ssh/dracut-crypt-ssh/issues). ## 5.3 Debugging a remote host If (or rather "when") something goes wrong and you can't access just-booted machine over network and can't get to console (hence sshd in initramfs), don't panic - it's fixable if the machine can be rebooted into some rescue system remotely. Usually it's some dhcp+tftp netboot thing from a co-located machine (good idea to setup/test in advance) plus whoever is there occasionally pushing the power button, or maybe some fancy hw/interface for that (e.g. hetzner "rescue" interface). To see what was going on during initramfs, open "modules.d/99base/rdsosreport.sh" in dracut, append this (to the end): set -x netstat -lnp netstat -np netstat -s netstat -i ip addr ip ro set +x exec >/dev/null 2>&1 mkdir /tmp/myboot mount /dev/sda2 /tmp/myboot cp /run/initramfs/rdsosreport.txt /tmp/myboot/ umount /tmp/myboot rmdir /tmp/myboot Be sure to replace `/dev/sda2` with whatever device is used for /boot, rebuild dracut and add `rd.debug` to cmdline (e.g. in grub.cfg's "linux" line). Upon next reboot, *wait* for at least a minute, since dracut should give up on trying to boot the system first, then it will store full log of all the stuff modules run ("set -x") and their output in "/boot/rdsosreport.txt". Naturally, to access that, +1 reboot into some "rescue" system might be needed. In case of network-related issues - e.g. if "rdsosreport.txt" file gets created with "rd.debug", but host can't be pinged/connected-to for whatever reason - either enable "debug" dracut module or add `dracut_install netstat ip` line to `install()` section of "modules.d/60dropbear-sshd/module-setup.sh" and check "rdsosreport.txt" or console output for whatever netstat + ip commands above (for "rdsosreport.sh") show - there can be no default route, whatever interface naming mixup, no traffic (e.g. unrelated connection issue), etc. ## 5.4 Report a bug If you suspect a bug in the software, please [report it via our issue tracker](https://github.com/dracut-crypt-ssh/dracut-crypt-ssh/issues). # 6. Security warning The integrity, confidentiality and authenticity of your encrypted data relies on the physical integrity of your device. If someone else has access to the device that you are unlocking, it is entirely possible to replace the executable files handling your key material, or steal your initramfs's SSH private keys. Arguably, this kind of attack is possible without the "crypt-ssh" module, but using automated or remote access could make such an attack easier to conceal. If this is a concern for you, consider keeping your devices offline and on your person. If this is not a concern for you, i.e. you place a certain amount of trust in your hosting provider or physical integrity, this tool might still protect against accidental data leaks (i.e. VM deprovisioning, replaced hard disks). 07070100000004000081ED000003E800000064000000015BD6D71500000A73000000000000000000000000000000000000003200000000dracut-crypt-ssh-1.0.7+20181029.2204f72/configure#!/bin/bash while [[ $# -gt 0 ]]; do case $1 in --print-moduledir) [[ -f config.mk ]] && source config.mk [[ -z $DRACUT_MODULEDIR ]] && exit 1 echo $DRACUT_MODULEDIR exit 0 ;; --dracut) DRACUT=$2 shift ;; --root-home) ROOTHOME=$2 shift ;; esac shift done echo -n "Searching for dracut... " if [[ -z $DRACUT ]]; then DRACUT=$(which dracut) if [[ $? -eq 0 ]]; then echo $DRACUT else echo "not found" exit 1 fi else echo "[provided] $DRACUT" fi echo -n "Checking dracut version... " DRACUT_VERSION=$(${DRACUT} --help | egrep "Version:[ \t]+[0-9]+" | egrep -o [0-9]+) if [[ $? -ne 0 ]]; then echo -n "[old version - fallback] " DRACUT_VERSION=004 else DRACUT_VERSION=$(echo ${DRACUT_VERSION} | cut -f 1 -d " ") fi echo ${DRACUT_VERSION} echo -n "Checking dracut module prefix... " DRACUT_MODULEDIR="" if [[ -d /usr/lib/dracut/modules.d ]]; then DRACUT_MODULEDIR=/usr/lib/dracut/modules.d elif [[ -d /usr/share/dracut/modules.d ]]; then DRACUT_MODULEDIR=/usr/share/dracut/modules.d else echo "failed" exit 1 fi echo ${DRACUT_MODULEDIR} NEED_CRYPTSETTLE=0 CRYPTPARSE=${DRACUT_MODULEDIR}/90crypt/parse-crypt.sh if [[ -f $CRYPTPARSE ]]; then echo -n "Checking whether crypt-settle patch is needed... " grep -q -- "--settled" ${CRYPTPARSE} if [[ $? -ne 0 ]]; then NEED_CRYPTSETTLE=1 echo "yes" else echo "no" fi fi echo -n "Checking for old-style modules... " OLDSTYLE=1 if [[ -f ${DRACUT_MODULEDIR}/99base/module-setup.sh ]]; then OLDSTYLE=0 echo "no" else echo "yes" fi echo -n "Checking for root's home... " if [[ -z ${ROOTHOME} ]]; then ROOTHOME=/ module=module-setup.sh [[ ${OLDSTYLE} -eq 1 ]] && module=install MODULEBASE=${DRACUT_MODULEDIR}/99base/${module} if [[ -f $MODULEBASE ]]; then grep -c "root:" ${MODULEBASE} >/dev/null if [[ $? -eq 0 ]]; then ROOTHOME=/root fi fi else echo -n "[provided] " fi echo ${ROOTHOME} echo -n "Checking for libnss_files.so ... " DIRS="/usr/lib /usr/lib64 /lib64 /lib" NSSFILES="" for dir in ${DIRS}; do for check in ${dir}/libnss_files.so*; do if [[ -f $check ]]; then NSSFILES=${check} break fi done done if [[ -z $NSSFILES ]]; then echo "not found" exit 1 else echo $NSSFILES fi OLDDRACUT=0 [[ $DRACUT_VERSION -le 4 ]] && OLDDRACUT=1 cat >config.mk <<EOF export DRACUT=${DRACUT} export DRACUT_VERSION=${DRACUT_VERSION} export DRACUT_MODULEDIR=${DRACUT_MODULEDIR} export NEED_CRYPTSETTLE=${NEED_CRYPTSETTLE} export ROOTHOME=${ROOTHOME} export OLDSTYLE=${OLDSTYLE} export NSSFILES=${NSSFILES} export OLDDRACUT=${OLDDRACUT} EOF 07070100000005000081A4000003E800000064000000015BD6D715000007BD000000000000000000000000000000000000003700000000dracut-crypt-ssh-1.0.7+20181029.2204f72/crypt-ssh.conf# NOTE: The defaults in this file MUST be carefully read and understood before using this module! # The defaults may NOT be appropriate for your site. Carefully review and understand your threat model # (ie, what attack scenarios you are protecting yourself against) and adjust accordingly! # # The port to run the ssh daemon on # Default: 222 # dropbear_port="222" # Where to get the RSA and/or ECDSA keys for dropbear, options are: # GENERATE: generate a new one for each initrd run, the public key will be printed during the dracut build process # and on boot # SYSTEM: use (convert) the host key from the host system's SSH daemon. This will make the initrd ssh indistinguishable # from the running system - this may be a security risk, depending on your threat model, but simplifies # your client-side ssh configuration # /path/to/openssh_key: an absolute path to a host key, in OpenSSH format as generated by ssh-keygen. # A public key with '.pub' ending must be present too. # # It is recommend that you use the system one, or supply your own. If using the system key, be aware that an attacker # that can access your initrd could use the host key to impersonate the running system. This could allow them to attempt # an MITM attack. # # Default: GENERATE # dropbear_rsa_key="GENERATE" # dropbear_ecdsa_key="GENERATE" # Location of the list of authorized public keys that can log into the initrd ssh daemon # Defaults to the authorized_keys list for root. It may be advantageous to use a different authorized_keys list # so that users/machines that can unlock the machine are not necessarily given full root access after boot. # Note that root access to the initrd does give an attacker means to provide themselves with root access after boot, # especially if they hold the encryption keys to the root drive - choose carefully! # # Default: /root/.ssh/authorized_keys # dropbear_acl="/root/.ssh/authorized_keys" 07070100000006000041ED000003E800000064000000015BD6D71500000000000000000000000000000000000000000000003000000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules07070100000007000041ED000003E800000064000000015BD6D71500000000000000000000000000000000000000000000003C00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh07070100000008000081A4000003E800000064000000015BD6D715000001AE000000000000000000000000000000000000004E00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/50-udev-pty.rules# do not edit this file, it will be overwritten on update KERNEL=="pty[pqrstuvwxyzabcdef][0123456789abcdef]", GROUP="tty", MODE="0660" KERNEL=="tty[pqrstuvwxyzabcdef][0123456789abcdef]", GROUP="tty", MODE="0660" KERNEL=="ptmx", GROUP="tty", MODE="0666" KERNEL=="tty", GROUP="tty", MODE="0666" KERNEL=="tty[0-9]*", GROUP="tty", MODE="0620" KERNEL=="console", MODE="0600" KERNEL=="vcs|vcs[0-9]*|vcsa|vcsa[0-9]*", GROUP="tty" 07070100000009000081A4000003E800000064000000015BD6D7150000016C000000000000000000000000000000000000004500000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/MakefileINSTDIR=$(MODULEDIR)/60crypt-ssh SUBDIRS=helper .PHONY: install all clean $(SUBDIRS) all: $(SUBDIRS) clean: $(SUBDIRS) install: $(SUBDIRS) mkdir -p $(INSTDIR) install -m 0644 50-udev-pty.rules $(INSTDIR)/ install -m 0755 dropbear-start.sh dropbear-stop.sh $(INSTDIR)/ install -m 0755 module-setup.sh $(INSTDIR)/ $(SUBDIRS): $(MAKE) -C $@ $(MAKECMDGOALS) 0707010000000A000081A4000003E800000064000000015BD6D7150000021A000000000000000000000000000000000000004E00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/dropbear-start.sh#!/bin/sh . /etc/crypt-ssh.conf [ -f /tmp/dropbear.pid ] && kill -0 $(cat /tmp/dropbear.pid) 2>/dev/null || { info "sshd port: ${dropbear_port}" for keyType in $keyTypes; do eval fingerprint=\$dropbear_${keyType}_fingerprint eval bubble=\$dropbear_${keyType}_bubble info "Boot SSH ${keyType} key parameters: " info " fingerprint: ${fingerprint}" info " bubblebabble: ${bubble}" done /sbin/dropbear -s -j -k -p ${dropbear_port} -P /tmp/dropbear.pid [ $? -gt 0 ] && info 'Dropbear sshd failed to start' } 0707010000000B000081A4000003E800000064000000015BD6D715000000C8000000000000000000000000000000000000004D00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/dropbear-stop.sh#!/bin/sh [ -f /tmp/dropbear.pid ] || exit 0 read main_pid < /tmp/dropbear.pid kill -STOP ${main_pid} 2>/dev/null pkill -P ${main_pid} kill ${main_pid} 2>/dev/null kill -CONT ${main_pid} 2>/dev/null 0707010000000C000041ED000003E800000064000000015BD6D71500000000000000000000000000000000000000000000004300000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/helper0707010000000D000081A4000003E800000064000000015BD6D71500000264000000000000000000000000000000000000004C00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/helper/MakefileINSTDIR=$(MODULEDIR)/60crypt-ssh/helper CFLAGS+=-std=gnu99 -Wall CC?=gcc .PHONY: install all clean test all: console_auth unlock test: crypttab-test install: mkdir -p $(INSTDIR) install -m 0755 console_peek.sh unlock-reap-success.sh $(INSTDIR)/ install -m 0755 unlock console_auth $(INSTDIR)/ clean: rm -f *.o console_auth unlock crypttab-test console_auth: auth.c $(CC) $(CFLAGS) $^ -o $@ unlock: crypttab.o unlock.o $(CC) $(CFLAGS) -lblkid $^ -o $@ crypttab-test: crypttab-test.c crypttab.o crypttab-test-data $(CC) crypttab-test.c $(CFLAGS) crypttab.o -lblkid -o crypttab-test ./crypttab-test 0707010000000E000081A4000003E800000064000000015BD6D715000002D1000000000000000000000000000000000000004A00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/helper/auth.c#include <sys/ioctl.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <termios.h> #include <unistd.h> #include <string.h> // Based on: // https://bugzilla.redhat.com/show_bug.cgi?id=524727 // http://roosbertl.blogspot.de/2012/12/centos6-disk-encryption-with-remote.html const char *prompt="Passphrase: "; int main (int argc, const char * argv[]) { char *passphrase; int i; int fd = open("/dev/console", O_RDONLY); if (fd < 0) return 2; passphrase = getpass(prompt); for (const char * str = passphrase; *str; ++str) ioctl(fd, TIOCSTI, str); ioctl(fd, TIOCSTI, "\r"); // clear string immediately int len = strlen(passphrase); for (i=0;i<len;i++) passphrase[i] = 0; return 0; } 0707010000000F000081ED000003E800000064000000015BD6D7150000004E000000000000000000000000000000000000005300000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/helper/console_peek.sh#!/bin/sh N=${1:-1} exec setterm -term linux -dump "$N" -file /proc/self/fd/1 07070100000010000081A4000003E800000064000000015BD6D71500000186000000000000000000000000000000000000005600000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/helper/crypttab-test-dataluks-b88c3187-3abd-4eb6-810e-3679c912902e UUID=b88c3187-3abd-4eb6-810e-3679c912902e none luks-e3967355-5de9-4150-bf47-5c5d88c660d2 UUID=e3967355-5de9-4150-bf47-5c5d88c660d2 # Comment # More comments # Malformed # Comments # That break the spec # Empty line follows luks-970223b4-62b6-400a-b0ac-74405ca9668d /dev/mapper/raid-array-1 /etc/mykey options moo bar baz fooo double 07070100000011000081A4000003E800000064000000015BD6D715000006E9000000000000000000000000000000000000005300000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/helper/crypttab-test.c#include <stdio.h> #include <string.h> #include "crypttab.h" const static int numExpectedResults = 4; const static struct crypttab_entry expectedResults[ 4 ] = { {"luks-b88c3187-3abd-4eb6-810e-3679c912902e", "UUID=b88c3187-3abd-4eb6-810e-3679c912902e", NULL, "none"}, {"luks-e3967355-5de9-4150-bf47-5c5d88c660d2", "UUID=e3967355-5de9-4150-bf47-5c5d88c660d2", NULL, "none"}, {"luks-970223b4-62b6-400a-b0ac-74405ca9668d", "/dev/mapper/raid-array-1", NULL, "/etc/mykey" }, {"moo", "bar", NULL, "baz" } }; int check_string( const char *name, const char*reference, const char*test ) { if( strcmp( reference, test ) != 0 ) { printf( "Mismatch: %s, expected %s got %s\n", name, reference, test ); return 0; } return 1; } int compare_entries( const struct crypttab_entry *reference, const struct crypttab_entry *test ) { return check_string( "mapper", reference->mapper, test->mapper ) && check_string( "device", reference->device, test->device ) && check_string( "keyfile",reference->keyfile, test->keyfile ); } int main( int argc, char **argv ) { struct crypttab crypttab = crypttab_parse( "./crypttab-test-data" ); int testsPassed = 0; int testsToPass = 1 + numExpectedResults; if( crypttab.size != numExpectedResults ) { printf( "Did not get the right number of entries! Got %i, expected %i\n", crypttab.size, numExpectedResults ); } else { testsPassed ++; } for( int line = 0; line < crypttab.size && line < numExpectedResults; ++line ) { testsPassed += compare_entries( &expectedResults[ line ], &crypttab.entries[ line ] ); } printf( "Tests %i/%i passed\n", testsPassed, testsToPass ); if( testsPassed == testsToPass ) { printf( "PASSED\n" ); return 0; } else { printf( "FAILED\n" ); return 255; } } 07070100000012000081A4000003E800000064000000015BD6D71500000C86000000000000000000000000000000000000004E00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/helper/crypttab.c#include <stdio.h> #include <linux/limits.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include "crypttab.h" #include <blkid/blkid.h> char *crypttab_skipwhitespace( char *line ); char *crypttab_parsefield( char *line, char *dest ); struct crypttab_entry *crypttab_parseline( char *line ); int crypttab_resize( struct crypttab *list, int newsize ); char *crypttab_skipwhitespace( char *line ) { if( line == NULL ) return NULL; for( ; line[ 0 ] != '\0' && isspace( *line ); ++line ) { if( line[ 0 ] == '\0' ) return NULL; } return line; } char *crypttab_parsefield( char *line, char *dest ) { int chr = 0; line = crypttab_skipwhitespace( line ); if( line == NULL ) { dest[ 0 ] = '\0'; return NULL; } for( ; line[ chr ] != '\0' && !isspace( line[ chr ] ); ++chr ) { dest[ chr ] = line[ chr ]; if( chr >= (PATH_MAX - 1 ) ) break; } dest[ chr ] = '\0'; return (line + chr ); } struct crypttab_entry *crypttab_parseline( char *line ) { struct crypttab_entry *entry = NULL; line = crypttab_skipwhitespace( line ); if( line == NULL ) { return NULL; } if( line[ 0 ] == '#' || line[ 0 ] == '\0' ) { return NULL; } entry = calloc( 1, sizeof( struct crypttab_entry ) ); if( !entry ) return NULL; entry->real_device = NULL; line = crypttab_parsefield( line, entry->mapper ); line = crypttab_parsefield( line, entry->device ); line = crypttab_parsefield( line, entry->keyfile ); // Normalise data if( entry->keyfile[ 0 ] == '\0' ) { strncpy( entry->keyfile, "none", PATH_MAX ); } return entry; } void crypttab_freeentry( struct crypttab_entry *entry ) { if( entry->real_device ) { free( entry->real_device ); } } int crypttab_resize( struct crypttab *list, int newSize ) { if( list->entries ) { struct crypttab_entry *newList = realloc( list->entries, sizeof( struct crypttab_entry ) * newSize ); if( newList ) { list->entries = newList; list->size = newSize; } else { crypttab_free( list ); } } else { list->entries = malloc( sizeof( struct crypttab_entry ) ); if( !list->entries ) { list->size = 0; } list->size = newSize; } return list->size; } void crypttab_free( struct crypttab *list ) { for( int entry = 0; entry < list->size; ++entry ) { crypttab_freeentry( list->entries + entry ); } free( list->entries ); list->size = 0; list->entries = NULL; } struct crypttab crypttab_parse( const char const*filename ) { struct crypttab list; char lineBuf[ PATH_MAX ]; FILE *file = NULL; list.size = 0; list.entries = NULL; file = fopen( filename, "r" ); if( !file ) return list; while( !feof( file ) ) { struct crypttab_entry *entry = NULL; fgets( lineBuf, PATH_MAX, file ); if( feof( file ) ) break; entry = crypttab_parseline( lineBuf ); if( entry ) { if( crypttab_resize( &list, list.size + 1 ) == 0 ) { return list; } list.entries[ list.size - 1 ] = *entry; } } return list; } void crypttab_lookupblkids( struct crypttab *list ) { for( int entryIdx = 0; entryIdx < list->size; ++entryIdx ) { struct crypttab_entry *entry = list->entries + entryIdx; entry->real_device = blkid_evaluate_tag( entry->device, NULL, NULL ); } } 07070100000013000081A4000003E800000064000000015BD6D715000001E8000000000000000000000000000000000000004E00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/helper/crypttab.h#ifndef _CRYPTTAB_H_ #define _CRYPTTAB_H_ #include <linux/limits.h> struct crypttab_entry { char mapper[ PATH_MAX ]; char device[ PATH_MAX ]; char *real_device; char keyfile[ PATH_MAX ]; }; struct crypttab { struct crypttab_entry *entries; int size; }; struct crypttab crypttab_parse( const char const*filename ); void crypttab_lookupblkids( struct crypttab *list ); void crypttab_free( struct crypttab *list ); void crypttab_freeentry( struct crypttab_entry *entry ); #endif 07070100000014000081ED000003E800000064000000015BD6D715000000BB000000000000000000000000000000000000005A00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/helper/unlock-reap-success.sh#!/bin/sh SYSTEMD_CRYPTSETUP="$(ps -C systemd-cryptsetup -o pid=)" if [[ $? -eq 0 ]]; then # Systemd method kill -9 ${SYSTEMD_CRYPTSETUP} else # Older method pkill cryptroot-ask fi 07070100000015000081A4000003E800000064000000015BD6D71500001093000000000000000000000000000000000000004C00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/helper/unlock.c #include <sys/types.h> #include <sys/wait.h> #include <sys/mman.h> #include <unistd.h> #include <stdio.h> #include <string.h> #include <errno.h> #include <stdlib.h> #include "crypttab.h" static const int kPasswordSize = 8192; static const char *kDevPath = "/dev"; static const char *kCrypttabPath = "/etc/crypttab"; static const char *kNoKeyFile = "none"; int runchild( const char *input, int inputSize, const char *path, char *const args[] ) { int childStdin[ 2 ] = { -1, -1 }; pipe( childStdin ); pid_t childPid = fork(); int childStatus; if( childPid == 0 ) { // We are the child close( 0 ); close( childStdin[ 1 ] ); dup2( childStdin[ 0 ], 0 ); // make stdin int rc = execv( path, args ); exit( rc ); } else { close( childStdin[ 0 ] ); write( childStdin[ 1 ], input, inputSize ); close( childStdin[ 1 ] ); waitpid( childPid, &childStatus, 0 ); } if( WIFEXITED( childStatus ) ) { return WEXITSTATUS( childStatus ); } else { return 1; } } int main( int argc, const char ** argv ) { int numProvidedNames = argc - 1; const char **providedNames = argv + 1; struct crypttab crypttab = crypttab_parse( kCrypttabPath ); if( crypttab.size == 0 ) { fprintf( stderr, "/etc/crypttab is empty or invalid\n" ); return 254; } int *unlockList = calloc( crypttab.size, sizeof( int ) ); if( !unlockList ) { fprintf( stderr, "Could not allocate memory\n" ); return 255; } int devicesToUnlock = 0; int errorExit = 0; if( numProvidedNames > 0 ) { for( int providedName = 0; providedName < numProvidedNames; ++providedName ) { const char *name = providedNames[ providedName ]; int found = 0; for( int entryIdx = 0; entryIdx < crypttab.size; ++entryIdx ) { struct crypttab_entry *entry = crypttab.entries + entryIdx; if( strncmp( name, entry->mapper, strlen( name ) ) == 0 ) { unlockList[ entryIdx ] = 1; found = 1; ++devicesToUnlock; break; } } if( !found ) { fprintf( stderr, "LUKS device matching '%s' not found in /etc/crypttab\n", name ); errorExit = 1; } } } else { // Unless provided with a specific list of devices to unlock, // only open devices that don't require a keyfile for( int entryIdx = 0; entryIdx < crypttab.size; ++entryIdx ) { struct crypttab_entry *entry = crypttab.entries + entryIdx; if( strcmp( entry->keyfile, kNoKeyFile ) == 0 ) { unlockList[ entryIdx ] = 1; ++devicesToUnlock; } } } if( devicesToUnlock == 0 ) { fprintf( stderr, "Error: No decryptable devices found!\n" ); errorExit = 1; } if( errorExit ) { free( unlockList ); crypttab_free( &crypttab ); return 1; } if( !mlockall( MCL_FUTURE ) ) { fprintf( stderr, "Warning: Unable to lock memory, are you root?\n" ); } char password[ kPasswordSize ]; int passwordSize = 0; // Can't use fgets as no guarantee that characters are printable, etc for( int chr = 0; chr < kPasswordSize && !feof( stdin ); ++chr ) { int rc = fgetc( stdin ); if( rc == EOF ) { passwordSize = chr; break; } else { password[ chr ] = (unsigned char) rc; } } crypttab_lookupblkids( &crypttab ); for( int entryIdx = 0; entryIdx < crypttab.size; ++entryIdx ) { struct crypttab_entry *entry = crypttab.entries + entryIdx; if( !unlockList[ entryIdx ] ) continue; if( strncmp( kDevPath, entry->real_device, strlen( kDevPath ) ) != 0 ) { fprintf( stderr, "Error: disk device '%s' not found\n", entry->device ); errorExit = 1; break; } // Right, now we have something to unlock char *path = "/sbin/cryptsetup"; char *args[] = { path, "luksOpen", entry->real_device, entry->mapper, NULL }; int result = runchild( password, passwordSize, path, args ); if( result ) { fprintf( stderr, "Could not open %s (%s)\n", entry->mapper, entry->real_device ); errorExit = 1; break; } } crypttab_free( &crypttab ); free( unlockList ); // Clear any record of password from RAM memset( password, '\0', kPasswordSize ); if( !errorExit ) { // Fork ourselves and run the cleanup script // Fork so that our return code isn't affected by the script if( fork() == 0 ) { system( "/sbin/unlock-reap-success" ); } } return errorExit; } 07070100000016000081A4000003E800000064000000015BD6D71500000D2C000000000000000000000000000000000000004C00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/60crypt-ssh/module-setup.sh#!/bin/bash # called by dracut check() { #check for dropbear require_binaries dropbear || return 1 return 0 } depends() { echo network return 0 } install() { #some initialization [[ -z "${dropbear_port}" ]] && dropbear_port=222 [[ -z "${dropbear_acl}" ]] && dropbear_acl=/root/.ssh/authorized_keys local tmpDir=$(mktemp -d --tmpdir dracut-crypt-ssh.XXXX) local keyTypes="rsa ecdsa" local genConf="${tmpDir}/crypt-ssh.conf" local installConf="/etc/crypt-ssh.conf" #start writing the conf for initramfs include echo -e "#!/bin/bash\n\n" > $genConf echo "keyTypes='${keyTypes}'" >> $genConf echo "dropbear_port='${dropbear_port}'" >> $genConf #go over different encryption key types for keyType in $keyTypes; do eval state=\$dropbear_${keyType}_key local msgKeyType=$(echo "$keyType" | tr '[:lower:]' '[:upper:]') [[ -z "$state" ]] && state=GENERATE local osshKey="${tmpDir}/${keyType}.ossh" local dropbearKey="${tmpDir}/${keyType}.dropbear" local installKey="/etc/dropbear/dropbear_${keyType}_host_key" case ${state} in GENERATE ) ssh-keygen -t $keyType -f $osshKey -q -N "" -m PEM || { derror "SSH ${msgKeyType} key creation failed" rm -rf "$tmpDir" return 1 } ;; SYSTEM ) local sysKey=/etc/ssh/ssh_host_${keyType}_key [[ -f ${sysKey} ]] || { derror "Cannot locate a system SSH ${msgKeyType} host key in ${sysKey}" derror "Start OpenSSH for the first time or use ssh-keygen to generate one" return 1 } cp $sysKey $osshKey cp ${sysKey}.pub ${osshKey}.pub ;; * ) [[ -f ${state} ]] || { derror "Cannot locate a system SSH ${msgKeyType} host key in ${state}" derror "Please use ssh-keygen to generate this key" return 1 } cp $state $osshKey cp ${state}.pub ${osshKey}.pub ;; esac #convert the keys from openssh to dropbear format dropbearconvert openssh dropbear $osshKey $dropbearKey > /dev/null 2>&1 || { derror "dropbearconvert for ${msgKeyType} key failed" rm -rf "$tmpDir" return 1 } #install and show some information local keyFingerprint=$(ssh-keygen -l -f "${osshKey}") local keyBubble=$(ssh-keygen -B -f "${osshKey}") dinfo "Boot SSH ${msgKeyType} key parameters: " dinfo " fingerprint: ${keyFingerprint}" dinfo " bubblebabble: ${keyBubble}" inst $dropbearKey $installKey echo "dropbear_${keyType}_fingerprint='$keyFingerprint'" >> $genConf echo "dropbear_${keyType}_bubble='$keyBubble'" >> $genConf done inst_rules "$moddir/50-udev-pty.rules" inst $genConf $installConf inst_hook pre-udev 99 "$moddir/dropbear-start.sh" inst_hook pre-pivot 05 "$moddir/dropbear-stop.sh" inst "${dropbear_acl}" /root/.ssh/authorized_keys #cleanup rm -rf $tmpDir #install the required binaries dracut_install pkill setterm /lib64/libnss_files.so.2 inst $(which dropbear) /sbin/dropbear #install the required helpers inst "$moddir"/helper/console_auth /bin/console_auth inst "$moddir"/helper/console_peek.sh /bin/console_peek inst "$moddir"/helper/unlock /bin/unlock inst "$moddir"/helper/unlock-reap-success.sh /sbin/unlock-reap-success } 07070100000017000081A4000003E800000064000000015BD6D71500000041000000000000000000000000000000000000003900000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/check.sh#!/bin/bash source $(dirname $0)/module-setup.sh check exit $? 07070100000018000041ED000003E800000064000000015BD6D71500000000000000000000000000000000000000000000004200000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/cryptsettle-patch07070100000019000081A4000003E800000064000000015BD6D71500000147000000000000000000000000000000000000004B00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/cryptsettle-patch/MakefileINSTDIR=$(MODULEDIR)/91cryptsettle-patch/ .phony: install all clean all: clean: install: ../install.sh ../check.sh module-setup.sh mkdir -p $(INSTDIR) install -m 0755 module-setup.sh $(INSTDIR)/ ifeq ($(OLDSTYLE),1) install -m 0755 ../install.sh $(INSTDIR)/install install -m 0755 ../check.sh $(INSTDIR)/check endif 0707010000001A000081A4000003E800000064000000015BD6D715000000D7000000000000000000000000000000000000005200000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/cryptsettle-patch/module-setup.sh#!/bin/bash check() { return 0 } install() { for file in ${initdir}/cmdline/*parse-crypt.sh; do dinfo "Patching ${file}" sed -i -e "s!/sbin/initqueue!/sbin/initqueue --settled!g" ${file} done return 0 } 0707010000001B000081A4000003E800000064000000015BD6D71500000038000000000000000000000000000000000000003B00000000dracut-crypt-ssh-1.0.7+20181029.2204f72/modules/install.sh#!/bin/bash source ${moddir}/module-setup.sh install 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!117 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor