mirror of
https://github.com/suiryc/archlinux-initrd-ssh-cryptsetup.git
synced 2025-12-16 01:28:57 +03:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3449995d4a | ||
|
|
c3cafcf6cd |
19
ChangeLog
19
ChangeLog
@@ -1,3 +1,22 @@
|
||||
2021-11-12 Julien Coloos <julien.coloos [at] gmail [dot] com>
|
||||
|
||||
* v0.10-1
|
||||
Option to use login shell instead of cryptsetup script
|
||||
Re-enable Wake-on-LAN on network device
|
||||
|
||||
|
||||
2021-11-12 Julien Coloos <julien.coloos [at] gmail [dot] com>
|
||||
|
||||
* v0.9-2
|
||||
Use SHA256 checksums instead of MD5
|
||||
|
||||
|
||||
2021-10-24 Julien Coloos <julien.coloos [at] gmail [dot] com>
|
||||
|
||||
* v0.9-1
|
||||
Try to print network devices information when interface setup fails
|
||||
|
||||
|
||||
2021-08-15 Julien Coloos <julien.coloos [at] gmail [dot] com>
|
||||
|
||||
* v0.8-1
|
||||
|
||||
8
PKGBUILD
8
PKGBUILD
@@ -1,17 +1,17 @@
|
||||
# Maintainer: Julien Coloos <julien.coloos [at] gmail [dot] com>
|
||||
pkgname=initrd-ssh-cryptsetup
|
||||
pkgver=0.8
|
||||
pkgver=0.10
|
||||
pkgrel=1
|
||||
pkgdesc="Allows for LUKS-encrypted devices to be unlocked remotely over SSH"
|
||||
arch=('any')
|
||||
url="https://github.com/suiryc/archlinux-$pkgname"
|
||||
license=('GPL3')
|
||||
depends=('dropbear' 'cryptsetup' 'mkinitcpio-nfs-utils' 'iproute2')
|
||||
depends=('dropbear' 'cryptsetup' 'mkinitcpio-nfs-utils' 'iproute2' 'ethtool')
|
||||
install=$pkgname.install
|
||||
changelog='ChangeLog'
|
||||
source=("http://julien.coloos.free.fr/archlinux/$pkgname-$pkgver.tar.xz" "$pkgname.install")
|
||||
md5sums=('ac5a53fbc288ccce61874488bcbbf58a'
|
||||
'ac60109d80e7bb2af0d66e69aaf178a6')
|
||||
sha256sums=('c3fa91fc8ba2228b3492d3709231918c8015cc3da49f516c3eacea5c0217536c'
|
||||
'b84978b3c2ef32208c2b104ee2d3ce8aaec26da0bd4e9e1c83942f373bbf6285')
|
||||
|
||||
package() {
|
||||
install -Dm644 "$srcdir/src/install/ssh-cryptsetup" "$pkgdir/usr/lib/initcpio/install/ssh-cryptsetup"
|
||||
|
||||
@@ -30,6 +30,7 @@ As explained upon installation, the following things need to be done:
|
||||
* add the authorized SSH public key to `/etc/dropbear/initrd.authorized_keys`
|
||||
* add the `ip=` kernel command parameter to the bootloader configuration (see https://wiki.archlinux.org/index.php/Mkinitcpio#Using_net)
|
||||
- e.g. with `grub`: add `ip=:::::eth0:dhcp` to `GRUB_CMDLINE_LINUX_DEFAULT` in `/etc/default/grub`, and re-generate the configuration with `grub-mkconfig -o /boot/grub/grub.cfg`
|
||||
- also see https://git.kernel.org/pub/scm/libs/klibc/klibc.git/tree/usr/kinit/ipconfig/README.ipconfig
|
||||
* in the `HOOKS` section of `/etc/mkinitcpio.conf`, add `ssh-cryptsetup` before `filesystems`; then rebuild the initramfs: `mkinitcpio -p linux`
|
||||
- when using a non-standard keyboard layout, it is also useful to add the `keymap` hook before `ssh-cryptsetup`, and also move `keyboard` before `keymap`
|
||||
|
||||
@@ -58,10 +59,11 @@ For example:
|
||||
## Building notes
|
||||
1. Modify the sources (features in `src`, and/or package building files)
|
||||
2. If `src` was modified
|
||||
* archive the `src` folder in `$pkgname-$pkgver.tar.xz` file; e.g.: `tar -cJf initrd-ssh-cryptsetup-0.7.tar.xz src`
|
||||
* archive the `src` folder in `$pkgname-$pkgver.tar.xz` file; e.g.: `tar -cJf initrd-ssh-cryptsetup-0.9.tar.xz src`
|
||||
* upload the archive on the online repository (pointed by `PKGBUILD`)
|
||||
3. Update ChangeLog
|
||||
4. Update `PKGBUILD`
|
||||
* bump `pkgver` if `src` was modified, or `pkgrel` if building files were modified
|
||||
* refresh `md5sums` if necessary (based on `md5sum initrd-ssh-cryptsetup-*.tar.xz initrd-ssh-cryptsetup.install` output)
|
||||
* refresh `sha256sums` with `updpkgsums` if necessary
|
||||
- or manually, based on `sha256sum initrd-ssh-cryptsetup-*.tar.xz initrd-ssh-cryptsetup.install` output
|
||||
5. Delete generated archive file if any
|
||||
|
||||
@@ -8,12 +8,14 @@ sshcs_env_load() {
|
||||
local debug_default=0
|
||||
local timeout_ipconfig_default=10
|
||||
local timeout_poweroff_min=120
|
||||
local use_shell_default=0
|
||||
|
||||
[ -e "${sshcs_env}" ] && . "${sshcs_env}"
|
||||
[ -z "${sshcs_opt_debug}" ] && sshcs_opt_debug=${debug_default}
|
||||
[ -z "${sshcs_opt_timeout_ipconfig}" ] && sshcs_opt_timeout_ipconfig=${timeout_ipconfig_default}
|
||||
[ -n "${sshcs_opt_listen}" ] && sshcs_opt_listen="-p ${sshcs_opt_listen}"
|
||||
[ -z "${sshcs_opt_timeout_poweroff}" ] && sshcs_opt_timeout_poweroff=${timeout_poweroff_min}
|
||||
[ -z "${sshcs_opt_use_shell}" ] && sshcs_opt_use_shell=${use_shell_default}
|
||||
[ ${sshcs_opt_timeout_poweroff} -ge 0 ] && [ ${sshcs_opt_timeout_poweroff} -lt ${timeout_poweroff_min} ] && sshcs_opt_timeout_poweroff=${timeout_poweroff_min}
|
||||
}
|
||||
|
||||
@@ -40,9 +42,12 @@ sshcs_net_start() {
|
||||
|
||||
echo ""
|
||||
echo "Configuring IP (timeout = ${sshcs_opt_timeout_ipconfig}s) ..."
|
||||
# ipconfig manual: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/tree/usr/kinit/ipconfig/README.ipconfig
|
||||
ipconfig_out=$(ipconfig -t "${sshcs_opt_timeout_ipconfig}" "ip=${ip}")
|
||||
if [ $? -ne 0 ]; then
|
||||
err "IP configuration timeout!"
|
||||
echo "Devices probing:"
|
||||
ipconfig -n -t 5 -c none all
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -131,11 +136,15 @@ sshcs_dropbear_unlock() {
|
||||
fi
|
||||
|
||||
# /etc/passwd file for the root user
|
||||
echo "root:x:0:0:root:/root:${dropbear_login_shell}" > "/etc/passwd"
|
||||
echo "${dropbear_login_shell}" > "/etc/shells"
|
||||
if [ ${sshcs_opt_use_shell} -eq 0 ]; then
|
||||
echo "root:x:0:0:root:/root:${dropbear_cryptsetup_shell}" > "/etc/passwd"
|
||||
echo "${dropbear_cryptsetup_shell}" > "/etc/shells"
|
||||
else
|
||||
echo "root:x:0:0:root:/root:/usr/bin/ash" > "/etc/passwd"
|
||||
fi
|
||||
|
||||
# root login script
|
||||
cat <<EOF > "${dropbear_login_shell}"
|
||||
cat <<EOF > "${dropbear_cryptsetup_shell}"
|
||||
#!/usr/bin/ash
|
||||
|
||||
. "/init_functions"
|
||||
@@ -157,7 +166,7 @@ else
|
||||
fi
|
||||
echo ""
|
||||
EOF
|
||||
chmod a+x "${dropbear_login_shell}"
|
||||
chmod a+x "${dropbear_cryptsetup_shell}"
|
||||
|
||||
[ ! -d "/var/log" ] && mkdir -p "/var/log"
|
||||
touch "/var/log/lastlog"
|
||||
@@ -174,7 +183,7 @@ EOF
|
||||
kill $(cat "${path_dropbear_pid}")
|
||||
rm -f "${path_dropbear_pid}"
|
||||
fi
|
||||
rm -f "${sshcs_cryptsetup_script}" "${dropbear_login_shell}" "/etc/passwd" "/etc/shells" "/var/log/lastlog"
|
||||
rm -f "${sshcs_cryptsetup_script}" "${dropbear_cryptsetup_shell}" "/etc/passwd" "/etc/shells" "/var/log/lastlog"
|
||||
|
||||
# cleanup /dev/pts if necessary
|
||||
if [ ${dev_pts_mounted} -ne 0 ]; then
|
||||
@@ -254,7 +263,7 @@ run_hook() {
|
||||
local etc_crypttab="/etc/crypttab"
|
||||
local sshcs_env="/etc/initcpio/sshcs_env"
|
||||
local path_dropbear_pid="/.dropbear.pid"
|
||||
local dropbear_login_shell="/.cryptsetup_shell.sh"
|
||||
local dropbear_cryptsetup_shell="/.cryptsetup_shell.sh"
|
||||
local sshcs_cryptsetup_script="/.cryptsetup_script.sh"
|
||||
local net_env="/.net_env.sh"
|
||||
local line iparg net_address net_device ipconfig_out net_netmask net_gateway net_dns0 net_dns1
|
||||
@@ -306,3 +315,4 @@ run_hook() {
|
||||
# stop the network before going on in boot sequence
|
||||
sshcs_net_done
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@ build() {
|
||||
add_binary "dmsetup"
|
||||
add_binary "dropbear"
|
||||
add_binary "ip"
|
||||
add_binary "/usr/lib/initcpio/ipconfig" "/sbin/ipconfig"
|
||||
add_binary "/usr/lib/initcpio/ipconfig" "/bin/ipconfig"
|
||||
add_binary "ethtool"
|
||||
|
||||
# Our hook files
|
||||
[ -e "${sshcs_env}" ] && add_file "${sshcs_env}"
|
||||
@@ -127,3 +128,4 @@ if present or generated if missing. Fingerprints are displayed upon building
|
||||
the initramfs image.
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user