[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#496252: network-console: Add support for launching an SSH server during installer startup

Package: network-console
Version: 1.20
Severity: wishlist


While debugging #484366, I needed to debug cdebconf on a computer that
lacked a serial connection.  As I needed to have a shell to be able to
start gdb, I thought that I could use an SSH server in order to do that.

The attached patch against network-console adds an extra step during
debian-installer startup that just does that when "BOOT_DEBUG=3" and
"device=ethX" are specified on the command-line.

It's a little bit crude, but was truly helpful on solving that issue.
So even if we don't get this in tree, this can be left as a reference.

Jérémy Bobbio                        .''`. 
lunar@debian.org                    : :Ⓐ  :  # apt-get install anarchism
                                    `. `'` 
commit 6c68d46b0eb8e8dcd73551eeb6a227175506082c
Author: Jérémy Bobbio <lunar@debian.org>
Date:   Sat Aug 23 21:33:33 2008 +0200

    Add support for starting an SSH server during the installer startup.
    In order to ease the debugging of issues arising in cdebconf, an SSH
    server can now be launched during the installer startup.
    In order to do so, network-console must be built in the initrd, and the
    kernel command line must contain the "BOOT_DEBUG=3" and
    "device=<ethernet device>" options.
    The shell will be started after configuring the device using the
    DHCP client.

diff --git a/installer/doc/devel/internals/internals.xml b/installer/doc/devel/internals/internals.xml
index a3b4748..a0acb84 100644
--- a/installer/doc/devel/internals/internals.xml
+++ b/installer/doc/devel/internals/internals.xml
@@ -340,6 +340,16 @@ The boot process for the installer is similar to the boot of a regular system. A
+When <classname>network-console</classname> is built-in the initrd, it is also
+possible to start a SSH server during the installer startup. On top of
+specifiying <userinput>BOOT_DEBUG=3</userinput> on the command-line,
+<userinput>device=<replaceable>ethX</replaceable> must be added. A DHCP request
+will be issued on this device before starting the server. The connection can
+then be made by using "root" as user and "debug" as password. This method has
+proven useful to debug issues in <classname>cdebconf</classname>.
 It is possible to pass additional kernel and boot parameters. Kernel parameters are sometimes needed to get non-conformant hardware supported, or to install from serial console instead of an attached keyboard/display.
diff --git a/packages/network-console/Makefile b/packages/network-console/Makefile
index f982bd8..e000840 100644
--- a/packages/network-console/Makefile
+++ b/packages/network-console/Makefile
@@ -11,6 +11,8 @@ install-network-console:
 	install -m644 sshd_config $(DESTDIR)/etc/ssh
 	install -d $(DESTDIR)/usr/lib/post-base-installer.d/
 	install -m755 post-base-installer $(DESTDIR)/usr/lib/post-base-installer.d/80network-console
+	install -d $(DESTDIR)/lib/debian-installer-startup.d/
+	install -m755 debian-installer-startup $(DESTDIR)/lib/debian-installer-startup.d/S09network-console
 	rm -f gen-crypt
diff --git a/packages/network-console/debian-installer-startup b/packages/network-console/debian-installer-startup
new file mode 100755
index 0000000..73835d0
--- /dev/null
+++ b/packages/network-console/debian-installer-startup
@@ -0,0 +1,26 @@
+if [ "$BOOT_DEBUG" -le 2 ] || ! grep -q device= /proc/cmdline; then
+	exit 0
+DEVICE=$(sed -e 's/.* device=\([^ ]*\).*/\1/p' /proc/cmdline)
+dhclient $device
+if [ ! -f $KEY_FILE ]; then
+	ssh-keygen -b 2048 -t rsa -N '' -f $KEY_FILE -q
+echo "root:$(gen-crypt "debug"):1:0:99999:7:::" >> /etc/shadow
+KEY_FINGERPRINT=$(ssh-keygen -l -f $KEY_FILE | cut -f2 -d ' ')
+IPADDR=$(ip addr | grep '^[[:space:]]*inet ' | grep -v "127\.0\." | \
+	 head -n 1 | sed 's/.*inet \([0-9.]*\).*/\1/')
+echo "--- Debug SSH access enabled on $IPADDR"
+echo "---    fingerprint: $KEY_FINGERPRINT"
+echo ""
+echo "Press enter to continue."
+read dummy
diff --git a/packages/network-console/debian/changelog b/packages/network-console/debian/changelog
index f54de42..d003734 100644
--- a/packages/network-console/debian/changelog
+++ b/packages/network-console/debian/changelog
@@ -1,3 +1,13 @@
+network-console (1.21) UNRELEASED; urgency=low
+  [ Jérémy Bobbio ]
+  * Add support for starting an SSH server during the installer startup.
+    "BOOT_DEBUG=3" and "device=<ethernet device>" must be specified on the
+    command line.  The shell will be started after configuring the device
+    using the DHCP client.
+ -- Jérémy Bobbio <lunar@debian.org>  Sat, 23 Aug 2008 21:24:35 +0200
 network-console (1.20) unstable; urgency=low
   [ Martin Michlmayr ]

Attachment: signature.asc
Description: Digital signature

Reply to: