Installing packages in Ubuntu's live environment

Recently I wanted to boot Ubuntu's live CD and install the OpenSSH server in this live environment so I could access it from another computer.

This is no problem, but I'm using a Belgian keyboard layout. Although I have learned writing qwerty on an azerty keyboard, I thought it would be easier to change the keyboard layout.

I never remember the right syntax for setxkbmap, so I just started the graphical installer and went through the first steps until I had changed the keyboard layout.

Then I opened a terminal, set a password for the ubuntu user and installed the OpenSSH server:

ubuntu@ubuntu:~$ passwd
ubuntu@ubuntu:~$ sudo apt update
ubuntu@ubuntu:~$ sudo apt install --yes openssh-server

Uh-oh, the installation finished with an error. I investigated with sudo journalctl -xe:

Jul 13 08:48:51 ubuntu sshd[9072]: /etc/ssh/sshd_config: No such file or directory
Jul 13 08:48:51 ubuntu systemd[1]: ssh.service: Control process exited, code=exited, status=1/FAILURE

I was puzzled: why would this basic configuration file not be created? OK, I thought, let's just create the file and restart the OpenSSH server:

ubuntu@ubuntu:~$ sudo touch /etc/ssh/sshd_config
ubuntu@ubuntu:~$ sudo systemctl restart sshd

But then the logs showed another error:

Jul 13 08:51:45 ubuntu sshd[9144]: Privilege separation user sshd does not exist
Jul 13 08:51:45 ubuntu systemd[1]: ssh.service: Control process exited, code=exited, status=255/EXCEPTION

Wait a minute, this really can't be right. If the sshd user isn't even created, I did something seriously wrong. So I took a step back and looked at the original error message, which I brushed off earlier. I now saw it complained with "Could not open lock file /var/lib/apt/lists/lock". And then I remembered: oh, I left the installer window open! I closed the window and then ran:

ubuntu@ubuntu:~$ sudo apt --fix-broken install

This fixed the installation of OpenSSH server, after which I could access the live environment from another computer.

Moral #1 of the story

Don't let the installer window or other package management windows open while you're running package management tasks in the terminal.

Moral #2 of the story

Always read error messages carefully.