I have a piece of software I need running continuously on one of my Ubuntu virtual machines. Sadly, for some reason I cannot explain, that software requires a user be logged into the head. But my virtual machine barely has a head. And I certainly don’t want to be logged into it all the time. This post is about a workaround I found.
The Problem
This piece of software needs to be started manually after boot. Once it’s started, it’ll keep running as a daemon. Oddly, on that first startup, there needs to be an account logged into the head. If not, it’ll refuse to start. Even more oddly, you don’t even need to start it from the head. You simply need to have something connected to the head, and then you can do the rest over ssh.
I don’t get it either. But that’s what I have i…
I have a piece of software I need running continuously on one of my Ubuntu virtual machines. Sadly, for some reason I cannot explain, that software requires a user be logged into the head. But my virtual machine barely has a head. And I certainly don’t want to be logged into it all the time. This post is about a workaround I found.
The Problem
This piece of software needs to be started manually after boot. Once it’s started, it’ll keep running as a daemon. Oddly, on that first startup, there needs to be an account logged into the head. If not, it’ll refuse to start. Even more oddly, you don’t even need to start it from the head. You simply need to have something connected to the head, and then you can do the rest over ssh.
I don’t get it either. But that’s what I have in front of me.
The challenge is that I have this Ubuntu instance running as a virtual machine on my Proxmox host. There isn’t much of a head to be using! It technically does exist as a serial console, but no sane person is going to use it — sane people will use this virtual machine and software over ssh. Not exactly easy for me to get logged into the head.
The Solution
My uh… solution … is to have an account automatically log into the head after the system restarts. I can do that on my Ubuntu Noble virtual machine with a systemd unit.
Run this command: sudo systemctl edit [\[email protected\]](https://spin.atomicobject.com/cdn-cgi/l/email-protection)
and add this content into the editor that opens:
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin fletcher --keep-baud 115200,57600,38400,9600 - $TERM
Type=idle
(Fill in the appropriate user account after --autologin – in my case, that’s fletcher.)
Then run these commands to ensure systemd is aware of the new unit:
sudo systemctl daemon-reload
sudo systemctl enable --now [email protected]
sudo systemctl restart [email protected]
Now reboot and watch the machine boot. You should see it automatically login when it’s done booting.
The Obvious Security Problem
This thing is logging in automatically, so be mindful about whether you really need or want this, and what the security impact could be. In my case, this is a virtual machine running in my private, internal cluster that no one else can access. It’ll be okay.
Which tty?
The above code assumes ttys0 , since that is what the virtual machine’s serial display shows up as in Ubuntu Noble. Depending on your distribution and whether you’re using Proxmox or not, you may have a different tty. If so, adjust the tty in the filename and commands above.
Conclusion
Now that my account automatically logs into the head after reboot, this other piece of software is perfectly happy to let me start it, as needed, over SSH.
Thanks to a couple of references out there for helping me figure out how to do this: