Autologin at startup with VirtualBox

User42

New Member
Joined
Dec 17, 2025
Messages
4
Reaction score
2
Credits
38
Hello,

My Homelab is building.
I ordered new hardware but I need to wait a bit the delivery.

So, what I did, is to install VirtualBox in my previous computer and I put a Debian for multiple purpose.

Because it's my previous computer, I don't have enough keyboard and display to let them attach to this computer.
So, I put the specific Debian VM in my startup folder on my Windows 10 to start my Debian when I press the START button and Windows is ON.

My question is :
Is it possible to configure Debian to log in automatically with a specific user without asking the username and the password ?

Because I don't have any display, I can't enter my username and password but I would like to reach this Debian VM via SSH (from my current computer).
Do you know if it's possible ?
(FYI, I don't have any GUI installed, so gdm3 is not a solution ;)

Thx in advance :D
 


Why does the user need to login before anyone can ssh to the VM?
 
Is it possible to login from SSH before the user loggued in ?

I always though services like SSH start only when a user first login from the CLI
 
Is it possible to login from SSH before the user loggued in ?
Yes because ssh is a service that starts up during the system boot process, once the system is started you can login with ssh to connect to your user.
 
@bob466
Haha thx, honestly, I found some tips with that link ;)

@f33dm3bits
I'm feeling like an idiot because it was so logic ^^
I was entirely sure that it wasn't possible and that I needed to first login with a local account before to launch anything else ...
Thx a lot for your help, I'll try without Loggued in locally ;)
 
Years ago you could run any Distro in Virtualbox...it was like running a Distro on your computer but these days some Distros don't run very well in Virtualbox.
1766094926024.gif


If I really want to test a Distro...I'll install it on my spare SSD.
1766095076776.gif
 
Hahha it's work xD

But I need to log in with SSH to enable other services running in the Debian VM ^^
Do you have any clue on how to activate directly a service without being loggued in before ? Like for SSH but choosing which service I want to enable ^^

Thx in advance
 
You can't change/enable/start/stop a service without being logged into it or way or another.
You could automate this with something like ansible, but even that needs login credentials.

I am "assuming" (possibly incorrectly) this is a systemd version.

Code:
systemctl list-unit-files

That will show are the services you have installed currently and what is enabled/disabled.

Typically you would do something like this...
Code:
systemctl enable sshd

systemctl start sshd

If you want to make sure it's running OK...

Code:
systemctl status -l sshd
.

The last Debian I installed did not have the ufw firewall installed by default.
If it is installed, you will have to allow ssh.

Code:
sudo ufw allow ssh
 
Here is how I used to start virtualbox on boot. You will need to adjust to your liking but it works


script code place at /usr/local/bin/start_vms.sh make sure the file has the correct ownership vbox:vboxusers and is executable


#!/bin/bash
# /usr/local/bin/start_vms.sh
# Run as the user who owns the VMs (vbox)

VM_LIST=("vm1" "vm2" "vm3" "vm4")

for VM in "${VM_LIST[@]}"; do
echo "Starting $VM..."
VBoxManage startvm "$VM" --type headless
echo "Waiting 30 seconds before next VM..."
sleep 30
done


Install the service at the following location


/etc/systemd/system/vms-startup.service:


[Unit]
Description=Start VirtualBox VMs with delay
After=network.target vboxdrv.service

[Service]
Type=oneshot
User=vbox
Group=vboxusers
ExecStart=/usr/local/bin/start_vms.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Start the service


sudo systemctl daemon-reload


sudo systemctl enable vms-startup.service


sudo systemctl start vms-startup.service
 
That script is for the host (the computer the VM is running on). It's been a while since I've ran Virtual Box from command line.
But I see you have vms-sartup enabled near the bottom. I'm pretty sure you can remove those lines.
Once it's enabled, you shouldn't have to re0enable and re-start it everytime (unless something is broken).
 
Just the way I cut and pasted things. Start the service was just a note to do the following reloading the daemon and starting and enabling the service only need to be done once. I found this way of starting my vm's much more stable. Before I did this I would run and script logging in, locking the screen and running a startup script. It also worked. I found the method I scribbled out above was rock solid. I finally converted over to proxmox recently. I took some time and made sure I had a stable proxmox system. I travel a lot and really don't want to have to either go without or come up with a plan to recover like I was trying to repair a voyager spacecraft.
 
Just the way I cut and pasted things.
Can you edit your post with the bash script and add CODE tags, if you use the post editor I think there's a bash option too when you select CODE. That makes reading a code more readable.
Screenshot_2025-12-22+22:28:58.png

Screenshot_2025-12-22+22:29:02.png
 
Can you edit your post with the bash script and add CODE tags, if you use the post editor I think there's a bash option too when you select CODE. That makes reading a code more readable.
View attachment 29462
View attachment 29463
I agree the original data came from my wiki complete with such tags. I just cut and paste out of it. I will do better next time...:)
 


Follow Linux.org

Staff online

Members online


Top