Linux – How to reboot headless server with passphrase

headlesslinuxUbuntuubuntu server

I have an old desktop computer that I want to start using as a headless server.

With a monitor and a screen attached, I installed Ubuntu Server edition with encrypted LVM on the machine. After installation I rebooted and, still with the monitor and keyboard attached, filled out the passphrase and was able to login. I was able to login to the server from my laptop. So far so good.

Then I disconnected the monitor and keyboard and rebooted the desktop remotely over ssh from the laptop. Upon rebooting I heard two beeps. When I tried to login again via ssh I got the message:

$ ssh plectrophenax.local

ssh: Could not resolve hostname plectrophenax.local: Name or service not known

When I reattached the monitor to the server, I saw the message

Grub loading

Unlocking the disk /dev/disk/by-uuid/de99e2c0-56d7-473b-f134FF5bd634 (sda1_crypt)

Enter passphrase:

So apparently it was waiting for me to enter my passphrase before it would boot up.

So how do I enter this passphrase remotely?

Best Answer

You can do so by installing an SSH server into your initramfs. One easy possibility is to use early-ssh. It installs a Dropbear SSH server right into your initramfs. With that server running you can log into your server before the root fs mount and enter the LUKS password.

Related Question