generate ssh keys

Signed-off-by: Nico Schottelius <nico@wurzel.schottelius.org>
This commit is contained in:
Nico Schottelius 2015-06-16 11:14:50 +02:00
parent 9d35be6acd
commit cc144d9e8f
5 changed files with 38 additions and 53 deletions

View File

@ -11,22 +11,3 @@ initramfs=preos/boot/initramfs
./create_iso.sh preos preos.iso ./create_iso.sh preos preos.iso
exit 0 exit 0
run_earlyhook() {
kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf
systemd-tmpfiles --prefix=/dev --create --boot
/usr/lib/systemd/systemd-udevd --daemon --resolve-names=never
udevd_running=1
}
run_hook() {
msg ":: Triggering uevents..."
udevadm trigger --action=add --type=subsystems
udevadm trigger --action=add --type=devices
udevadm settle
}
run_cleanuphook() {
udevadm control --exit
udevadm info --cleanup-db
}

View File

@ -13,13 +13,17 @@ fi
out_dir=$1 out_dir=$1
# TODO:
# - various mkfs
#bin_list="udevadm bash fdisk mount syslinux umount rm mv" #bin_list="udevadm bash fdisk mount syslinux umount rm mv"
bin_list="udevadm fdisk" bin_list="udevadm fdisk sshd ssh-keygen"
# debug tools
bin_list="$bin_list strace less"
libs=$(mktemp /tmp/cdist-preos-libs.XXXXXXXXXXXXX) libs=$(mktemp /tmp/cdist-preos-libs.XXXXXXXXXXXXX)
mkdir -p "$out_dir/bin" "$out_dir/lib"
( (
for bin in $bin_list; do for bin in $bin_list; do
src=$(which "$bin") src=$(which "$bin")
@ -31,30 +35,10 @@ mkdir -p "$out_dir/bin" "$out_dir/lib"
while read lib; do while read lib; do
if echo $lib | grep '^/'; then if echo $lib | grep -q '^/'; then
# echo "Copying fqdn lib $lib ..." # echo "Copying fqdn lib $lib ..."
cp "$lib" "$out_dir/lib" cp "$lib" "$out_dir/lib"
else
echo "How to copy $lib ?"
fi fi
done < "$libs" done < "$libs"
rm -f "$libs" rm -f "$libs"
exit 0
bin=$1
# Not used alternatives
# new_list=$(objdump -p /usr/bin/ls | awk '$1 ~ /NEEDED/ { print $2 }')
# ldconfig -p | grep 'libBrokenLocale.so.1$' | sed 's/.* => //'
for new_item in $new_list; do
done
ldconfig -p |

View File

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
set -ex set -e
here=$(pwd -P)
initramfs_dir=$(mktemp -d /tmp/cdist-preos.XXXXXXX) initramfs_dir=$(mktemp -d /tmp/cdist-preos.XXXXXXX)
# initramfs_dir=$1 # initramfs_dir=$1
@ -22,10 +23,10 @@ cd "${initramfs_dir}"
# Add Arch Linux initramfs with kernel modules included # Add Arch Linux initramfs with kernel modules included
zcat /boot/initramfs-linux-fallback.img | cpio -i zcat /boot/initramfs-linux-fallback.img | cpio -i
# TODO: # Add helper binaries
# - ssh "$here/copy_bin_with_libs.sh" "$initramfs_dir" >/dev/null 2>&1
# - various mkfs "$here/sshd_config.sh" "$initramfs_dir"
# - libs
# Create new initramfs # Create new initramfs
find . | cpio -H newc -o | gzip find . | cpio -H newc -o | gzip

View File

@ -1,17 +1,16 @@
#!/bin/sh #!/bin/sh
#Create all the symlinks to /bin/busybox # Create all the symlinks to /bin/busybox
/bin/busybox --install -s /bin/busybox --install -s
#Mount things needed by this script # Mount things needed by this script
mount -t proc proc /proc mount -t proc proc /proc
mount -t sysfs sysfs /sys mount -t sysfs sysfs /sys
#Disable kernel messages from popping onto the screen # Disable kernel messages from popping onto the screen
echo 0 > /proc/sys/kernel/printk echo 0 > /proc/sys/kernel/printk
# Create device nodes
#Create device nodes
mknod /dev/null c 1 3 mknod /dev/null c 1 3
mknod /dev/tty c 5 0 mknod /dev/tty c 5 0
mdev -s mdev -s
@ -24,5 +23,10 @@ udevadm trigger --action=add --type=subsystems
udevadm trigger --action=add --type=devices udevadm trigger --action=add --type=devices
udevadm settle udevadm settle
# /bin/sshd
# Generate keys for sshd
echo "Generating keys for sshd"
ssh-keygen -A
exec sh exec sh

View File

@ -9,6 +9,7 @@ dir=$1
mkdir -p "$dir/etc/ssh" mkdir -p "$dir/etc/ssh"
mkdir -p "$dir/root/.ssh" mkdir -p "$dir/root/.ssh"
mkdir -p "$dir/lib"
cat << eof > "$dir/etc/ssh/sshd_config" cat << eof > "$dir/etc/ssh/sshd_config"
# cdist generated - do not modify # cdist generated - do not modify
@ -25,6 +26,20 @@ root:x:0:root
nobody:x:99: nobody:x:99:
eof eof
# libpam not found
# /etc/ssl/openssl.cnf
# /etc/gai.conf
# no nscd socket
# /etc/nsswitch.conf
# libnss_compat.so.2
# libnss_files.so.2
# Fixes the user problem
cp /lib/libnss* "$dir/lib"
# Required by sshd
mkdir -p "$dir/var/empty"
#cat << eof > "$dir/etc/shadow" #cat << eof > "$dir/etc/shadow"
#root:x:0:0:root:/root:/bin/bash #root:x:0:0:root:/root:/bin/bash
#nobody:x:1:::::: #nobody:x:1::::::