I'm trying to replicate locally the kind of image VPS providers (DigitalOcean, Vultur, etc) gives me when I deploy on their services. To my knowledge, their base images are pretty vanilla, so I though the official ubuntu server images would be just perfect to boot in Virtual Box and I'd be done with it. Problem is: the official image forces me to create a sudo user.
This is great in a normal usage, but when I spin an instance on a VPS, I'm starting only with root
as user. Is there any way to make an installation without sudo user with the official ISO image? (I'm open to a Vagrant Box is there is one too!)
Please note:
- I know running on
root
user is bad, I'm only doing it locally, "for science"; - I know I can
sudo su
from my user, but this is not what I want;
Again, I want to have it like they give it to me with the VPS providers… But thanks for your concerns on security 😉
Best Answer
This is a step-by-step example of how to do it by enabling root and deleting the user, as mentioned by user Byte Commander
USERNAME
created during installationsudo su
to become rootpasswd
and then password to give the root user a passwordnano /etc/ssh/sshd_config
with the following edit to allow root user ssh login#PermitRootLogin prohibit-password
and without modifying it, add the following new line below itPermitRootLogin yes
Ctrl-X
,y
,Enter
to save the changes and exit nanoservice ssh reload
to reload the ssh daemon configurationAt this point:
cut -d: -f1 /etc/passwd
should listUSERNAME
as the last entry.cut -d: -f1 /etc/group
should listUSERNAME
as the last entry.id
(when executed asUSERNAME
) should returnuid=1000(username) gid=1000(username) groups=1000(username),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lxd)
Now delete the user
USERNAME
:deluser --remove-home USERNAME
to delete the user created during installation. You will get a warningWarning: group 'USERNAME' has no more members.
, but this group will also be deleted automatically before the command finishes.At this point:
USERNAME
should be listed incut -d: -f1 /etc/passwd
.USERNAME
should be listed incut -d: -f1 /etc/group
.root
with the root password.While it may be the case that some stuff still refers to
USERNAME
, the way the system is at this point comes relatively close to what a VPS would offer, hopefully close enough to do some testing withAnsible
or similar.While that Kickstart-solution should be the correct one, this one may be easier to archive and offer nearly the same functionality.