[debian] initrd (cramfs) + ssh server
Hi,
I am not a member of this list. I searched the archives in vain, though I
have a chellenging problem to solve. Hopefully, the task is already solved
by someone, in this case I would welcome a site where the solution can be
read about. Otherwise I would appreciate any other ideas.
I would like to make my computer able to start an ssh server from initrd.
The main idea is that during bootup from initrd the partition comtaining
the system is checked. If the fs is found inconsistent (e2fsck fails) ssh
server is started, to give a means of maintainance from remote.
I am using linux kernel version 2.4.26-386-1 for the test. Network is
configured well, the machine can be pinged from remote. But when it comes
to starting sshd it tells ---> Privilege separation user sshd does not
exist though in /etc/passwd sshd is already added.
For the creation of initrd image initrd-tools were used. mkinitrd was
modified. Some useful binaries and scripts were added and symlinks were
created to files that cannot be readonly (Eg. /var/run/sshd.pid).
My linuxrc contains:
-----------------------------------------------------------------------
#!/bin/sh
export PATH=/sbin:/bin
mount -nt proc proc proc
root=$(cat proc/sys/kernel/real-root-dev)
mount -nt devfs devfs /devfs
for module in ide-core ide-disk piix ide-detect ext3 jbd; do
modprobe $module
done
ERROR=0
for part in part1 part3; do
e2fsck -p /dev/ide/host2/bus0/target0/lun0/$part || ERROR=1
done
if [ $ERROR -eq 1 ]; then
mount -nt tmpfs tmpfs /tmp
touch /tmp/syslogd.pid
touch /tmp/syslog
/etc/sysklogd start
modprobe e1000
mount -nt devpts devpts /dev/pts
echo myhostname > /proc/sys/kernel/hostname
touch /tmp/ifstate
mkdir /tmp/if-up.d /tmp/if-down.d /tmp/if-post-down.d /tmp/if-pre-up.d
/etc/network/networking start
touch /tmp/inetd.pid
/etc/inetd start
mkdir /tmp/sshd
touch /tmp/sshd.pid
cp -a /etc/passwd.ro /tmp/passwd
cp -a /etc/shadow.ro /tmp/shadow
cp -a /etc/group.ro /tmp/group
cp -a /etc/gshadow.ro /tmp/gshadow
/etc/ssh/ssh start
# just to get stopped
/bin/sh
for k in sshd syslogd inetd; do
/usr/bin/killall $k
done
umount -n /devfs
umount -n /dev/pts
umount -n /tmp
echo 256 > proc/sys/kernel/real-root-dev
mount -nt tmpfs tmpfs bin || mount -nt ramfs ramfs bin
echo $root > bin/root
else
umount -n /devfs
echo 256 > proc/sys/kernel/real-root-dev
mount -nt tmpfs tmpfs bin || mount -nt ramfs ramfs bin
echo 8451 > bin/root
fi
-----------------------------------------------------------------------
Thank you for your kind help in advance.
Cheers,
Jozsi
Reply to: