4

What is the lightest-ever Linux I could install on a VM just for SSH tunneling with openSSH?

I am looking for something light I could install fastly from any machine that can run Oracle VirtualBox.

Something with no more than 1 minute installation for a modern average PC (Intel I5, 12GB RAM).

I voluntarily avoid giving any further details, because the moment I can run VirtualBox I just need the lightest Linux you can think of, with about 1 minutes of installation as I explained, just for SSH tunneling. No other tasks basically.

2

Bare install of Debian - on the task select screen don't pick anything but "ssh server" and "standard system utilities". Will end up usign about 1gb and can be run in 128mb ram or perhaps less - but during install I'd use at least 256.

  • 1
    That seems like about 10 times more gear than is called for by the task. – Caleb Mar 21 '17 at 19:22
  • 1
    There are smaller distros... like DSL (50mb). But then adding in the standard openssh server becomes an issue. There is a lot you could do to slim it down - but with hundreds of gb of storage, and gigs of ram available, why bother? – ivanivan Mar 21 '17 at 20:34
  • You don't need to select standard system utilities. If you need something from that, you can install it manually later. It will run fine. – Maadinsh Mar 28 '17 at 10:40
4

Damn Small Linux

~250 MB, built-in SSH, available as a VirtualBox image to avoid installation. Everything you need ;)

There is lighter options, but what's the point at this size? (especially considering you'll have to add SSH yourself)

2
+50

Core - 11MB!

For virtual box, you can set up 128 RAM (recommended, it can work well with 64 RAM) and I suggest 20 MB hard disk (that depends on what you need).

Note: I did try with 16 MB, but did run out of space when trying to add openssh.


Installation

While this technically fails at the 1 minute installation. Once you have an installed VM, you can export it and import it anywhere you need it. Thank to the small size it only takes seconds to import.

Lazy? I exported one for you: Core Linux + Openssh for VirtualBox - tc password is CoreSecretLinux, root password is RootSecretLinux - I used a hard disk in VMware format just in case. I tested it with PuTTy on Windows.

Or if you prefer - or don't trust me enough - you can follow the steps below.


Boot with the .iso file from Core, just hit enter to log in. To install to disk follow these steps:

  1. Download the software needed to install to disk

    tce-load -w -i cfdisk
    tce-load -w -i grub-0.97-splash.tcz
    

    Note: since you want openssh, you may also do (you can do this after installation too)

    tce-load -w -i openssh.tcz
    

    These packages are being kept in RAM.

  2. Format the disk

    sudo cfdisk /dev/sda
    
  3. Using cfdisk create at least a primary bootable partition sda1 (select new -> primary -> set the size, select bootable, select write, type "yes", select quit).

  4. Format the partition with ext4

    mkfs.ext4 /dev/sda1
    
  5. Rebuild the file systems table

    sudo rebuildfstab
    
  6. Mount the partition we created

    mount /mnt/sda1
    
  7. Create the folder for grub installation

    sudo mkdir -p /mnt/sda1/boot/grub
    
  8. Create the folder for the core extensions

    sudo mkdir -p /mnt/sda1/tce/optional
    
  9. Mount the iso

    mount /mnt/sr0
    
  10. Copy boot from the iso to the partition

    sudo cp -p /mnt/sr0/boot/core.gz /mnt/sda1/boot
    sudo cp -p /mnt/sr0/boot/vmlinuz /mnt/sda1/boot
    
  11. Copy your extensions to the partition (Optional)

    sudo cp -p /tmp/tce/optional/* /mnt/sda1/tce/optional
    

    Note: here you are copying the packages you got with tce-load

  12. Create the configuration file that Core uses

    sudo touch /mnt/sda1/tce/mydata.tgz
    
  13. Copy grub to the partition

    sudo cp -p /usr/lib/grub/i386-pc/* /mnt/sda1/boot/grub
    
  14. Create the grub boot menu

    sudo vi /mnt/sda1/boot/grub/menu.lst
    

    Note: vi comes by default. And the keyboard configuration is US by default. I'd defer to A Beginner’s Guide to Editing Text Files With Vi if you need a quick introduction.

    Insert the following text:

    default 0
    timeout 0
    title Core
    kernel /boot/vmlinuz quiet
    initrd /boot/core.gz
    

    Write and quit.

  15. Invoke Grub for setup

    grub
    

    On grub:

    root (hd0,0) setup (hd0) quit

  16. unmount the iso

    sudo umount /mnt/sr0
    
  17. Eject the iso (via Virtual Box menus)

  18. Reboot

    sudo reboot
    

The machine should reboot to start from the virtual hard disk. The user you'll have is "tc" with no password. You will have to set the password with passwd if you want to use it with openssh.

You still need to configure your openssh. You can try following mileymattj tutorial for openssh.

I made this while writing to make sure I didn't skip any step. I was using Oracle VirtualBox 5.1.18r114002 - I used Core version 8.0 - For the purposes of installation, I've been following smileymattj tutorials.


Notes

  • Make sure that the boot order is correct (first CD, then hard disk).

  • If you are running out of space when adding an extension you get a messages saying that wget did a short write and that the checksum failed. It doesn't spell out that it was because of lack of space.

  • You can find the downloaded packages in /mnt/sda1/tce/optional if you want to remove them.

  • You may also want to get appbrowser-cli via tce-load for a more convinient way to download extensions.

  • If an extension has already been downloaded (for example if you copied it to the hard disk during installation), you can load it with tce-load -i (extension_name). Do not add -w if you don't intent to download the extension.

  • Add the extensions you want to load automatically to onboot.lst on /mnt/sda1/tce/ - for example if you want to autoload openssh, you can add a line with openssh.tcz on onboot.lst

  • It is worth noting is that Core Linux is designed to execute fully in RAM. See Tiny Core / Micro Core Persistent.

0

Pick one from this question and add openSSH.

My answer touches on various point & click "build your won distro" options, plus Puppy Linux, Damn Small Linux & other leightweight distros which are not at all resource hungry.

0

I would recommend to use Finnix (only about 135 MB for x86) and good if you want the Debian apt repo.

Another option (non Debian based) is Alpine (~130 MB).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.