Installing Debian using only SSH

Submit to reddit

I have a headless machine at home that I plan to use as a backup and development server. Even though I’m a Skackware guy I chose to install Debian on it. Of course I could have hooked a monitor and keyboard to it but for the sake of exercise I wanted to see if it’s possible to install debian using ssh from the very beginning.

The short answer: it’s possible … maybe. Your headless machine should already be set to boot of cd if one is present, otherwise it will not work.

Here are the steps needed to start you off:

1. Download the netinst cd image


2. Mount the ISO to a folder, let’s call it isoorig

mkdir isoorig
mount -o loop -t iso9660 debian-503-i386-netinst.iso isoorig

3. Extract to new folder called isonew

mkdir isonew
rsync -a -Hexclude=TRANS.TBL isoorig/ isonew

4. Change the menu to load SSH on boot by default

/isonew# nano isolinux/txt.cfg

remove “menu default” from “label install”


label netinstall
menu label ^Install Over SSH
menu default
kernel /install.386/vmlinuz
append auto=true vga=normal file=/cdrom/preseed.cfg initrd=/install.386/initrd.gz locale=en_US console-keymaps-at/keymap=us

“default install” to “default netinstall”

EDIT: both files below and change “timeout 0″ to “timeout 4″ to make it auto select netinstall

nano isolinux/isolinux.cfg
nano isolinux/prompt.cfg

5. Create preseed.cfg file

nano isonew/preseed.cfg

6. PASTE this to the preseed file:

#### Contents of the preconfiguration file
### Localization
# Locale sets language and country.
d-i debian-installer/locale select en_US
# Keyboard selection.
d-i console-keymaps-at/keymap select us
### Network configuration
# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto
# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/get_hostname string newdebian
d-i netcfg/get_domain string local
# Disable that annoying WEP key dialog.
d-i netcfg/wireless_wep string
# The wacky dhcp hostname that some ISPs use as a password of sorts.
#d-i netcfg/dhcp_hostname string radish
d-i preseed/early_command string anna-install network-console
# Setup ssh password
d-i network-console/password password install
d-i network-console/password-again password install

7. Recreate md5sum.txt file

md5sum `find -follow -type f` > md5sum.txt

8. Create your new iso image

mkisofs -o ../custom_install.iso -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/ ../isonew

The image you just obtained is ready to burn. This loads everything automatically and goes to the SSH screen.

Thanks go to people on various debian forums, this information was collected via trial and error and by combining info found around. Have fun with your shiny new headless debian box.

  • m7stic

    You are a godsend. I’ve been looking for a solution for this exact problem for a while now. Thank you!

  • Kiste_Becks

    in code paste 6, did you maybe put some code outside the codeblock?

    • Thanks for pointing it out, it’s fixed now.

  • Kiste_Becks

    mkdir isoorig
    mount -o loop -t iso9660 debian-6.0.3-i386-netinst.iso isoorig
    mkdir isonew
    rsync -a -H –exclude=TRANS.TBL isoorig/ isonew
    mkisofs -o ../custom_install.iso -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/ ../isonew

    just doing these steps doesnt work, am i wrong to assume that this should basically create the original image and boot it?

  • Kiste_Becks

    please ignore my last comments, i was copying the .iso directly to a usb stick.  i was assuming that the hybrid part is in the image….had to use unetbootin to make it boot.

  • Md. Mominul Islam

    i have downloaded “debian-6.0.3-i386-netinst.iso” (191 MB in one file) from net using i was trying to burn (with infra recorder) this file to dvd. after burning , it shows burning is successful but when i go to open it, it shows nothing.  Please send me the proper procedure. Mentionable that i have burnt this “debian-6.0.3-i386-DVD-1.iso” with infra recorder and result is successful.

  • Ralle5150

    Awesome tutorial! Works excellent with 6.0.4 as well, thanks a lot!