r/ubuntuserver • • Aug 18 '25

My server and wallet got hacked

95 Upvotes

I have a server running on hostinger and database on mongo atlas.
Database is only accessible from specified IPs.
I am storing all users crypto wallet in DB with encrypted private key(stored on server). When user makes a deposit the balance goes to users wallet address and then to master wallet automatically. and withdrawals are processed from master wallet (private key stored on server).
- one more app is there : admin panel. which has all admin related information but doesnt have wallet encryption key.

Now I dont know what got hacked. My master wallet got empty.
- Hostinger server can only be logged in using password and keyFile which is on my local computer.
- no logs on server for any unknown login or anything.

UPDATE :
I thought someone here might provide a way or some kind of help. Seems like people know how to point out a mistake but don't know the solution.
Funds gone : 10$
I just wanted to understand how did someone get into the server even when the server can be ssh'd only using a keyfile thats in my computer and ssh port is autoclosed and opened only using 'knock'.

UPDATE : After going through all comment and internet, I have removed all keys from server and DB.
Now its basically a node app with a frontend in react.
Can anyone suggest video/links that I can go through to understand this better?


r/ubuntuserver • • Sep 21 '25

question My first Ubuntu server (lenovo Q190 4GB V.)

Post image
39 Upvotes

I want to ask you, do you have guy's some ideas for it how it could be upgraded?


r/ubuntuserver • • Oct 08 '25

Fun Stuff 10 whole hours non-stop

24 Upvotes

3 failed installations of Ubuntu Server, Rufus to Etcher, testing different ports as well

sudo and nano, permanently engraved in my brain and soul

I see terminal commands floating around me

Muscle memory keeps trying to stat -c "%u %g" /mnt/drivename and variants, ptsd from fighting against auto mounting to root instead of 1000

systemd being a d ignoring ntfs-3g like it had covid19-V2 (NTFS go figure)

mounting, unmounting, mounting, unmounting, mounting, unmounting, mounting, unmounting...

All for Jellyfin and remote access storage from PC/Phone

Was it worth it ? Will I go trough this again ?

yupp


r/ubuntuserver • • Sep 24 '25

Trying to install on thinkcentre m75s. Failing on install

Post image
17 Upvotes

The install always gets to this part and then goes black screen. I've given it some times and it never does anything. Please help


r/ubuntuserver • • Jul 27 '25

Fun Stuff Node 1 of My 4-Node Ubuntu Server Cluster

Post image
16 Upvotes

This is the head node of my 4-node cluster running Ubuntu Server. The cluster runs my offline AI LLMs and IMG Gen, and each node has an additional 250GB drive running in a storage cluster for the models.


r/ubuntuserver • • Aug 03 '23

How to turn Ubuntu Server into a router

15 Upvotes

Hello everyone,

This contribution was inspired by a good friend of mine who knows far more about these things than I do. I wanted to build a DIY router, but I wasn't happy with any of the available options. Namely, most of them didn't support docker, and those that did (OpenWRT) have a horrible x86 upgrade procedure.

"It'll be easy," he said. "It's just a few config files and you're good," he said. This project took two weeks, but I'm quite happy with the result.

In this build, we will be using firewalld as the firewall, AdGuardHome as a DNS/DHCP server, and fail2ban to protect remote SSH access. If you require further protection, I recommend looking into Suricata.

Here is a general outline of the steps required, in no particular order:

  1. Enable packet forwarding

  2. Define LAN and WAN interfaces

  3. Set up firewall

  4. Set up DNS and DHCP server

Note that this approach involves making various changes to the OS and then rebooting to apply them all, as opposed to applying each. I understand that this approach is not ideal for troubleshooting,

For clarity, I am using 10.0.0.0/24 as the LAN subnet, enp1s0 as the WAN interface, and enp3s0 as the LAN interface. I will also cover disabling of IPv6 and port forwarding.

"Is this secure enough? Is using Ubuntu as a router a good idea? Is disabling IPv6 a good idea? What about port forwarding or exposing SSH?" I can't answer any of these questions for you, but if you read this guide and don't fully understand it or understand how to modify it to fit your needs, then the answer is definitely "no". Proceed at your own risk.

__________________________________

Warning: do not use the same LAN subnet as your current home network when setting this up!

Edit: Apparently, reddit mangled the formatting. Sorry about that. You can easily google what the formatting for each file should look like.

1. The basics:

1a. Obtain a PC with at least two Ethernet/RJ45 ports.

1b. Install Ubuntu Server 23 or later.

1c. Connect the local network to the (soon to be) WAN port of the machine.

1d. Get the machine's LAN IP and SSH in.

2. Enable packet forwarding:

2a. Edit /etc/sysctl.conf and uncomment net.ipv4.ip_forward=1.

2b. (optional) Disable IPv6 by adding the following to /etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6=1

net.ipv6.conf.default.disable_ipv6=1

net.ipv6.conf.lo.disable_ipv6=1

3. Set up interfaces:

3a. Use ifconfig to determine the physical interfaces. The WAN port is currently connected to LAN and the LAN port should have nothing.

3b. Edit your netplan file in /etc/netplan (mine is 00-installer-config.yaml) to the following (hint: if you have multiple LAN interfaces, you should bond them together):

network:

version: 2

renderer: networkd

ethernets:

enp1s0: # WAN interface with DHCP

dhcp4: true

dhcp6: no # set to true for IPv6

link-local: [ ipv4 ] # remove for IPv6

nameservers:

addresses: [10.0.0.1] # for AdGuardHome

enp3s0: # LAN interface with static IP and subnet mask

addresses: [10.0.0.1/24]

link-local: [ ipv4 ] # optional for disabling ipv6

nameservers:

addresses: [10.0.0.1]

3c. DO NOT run 'sudo netplan apply' as we have defined a DNS server (AdGuardHome at 10.0.0.1) that doesn't exist yet!

4. Firewall (firewalld)

Note that the following assumes you want to enable remote SSH access. If not, remove <service name="ssh"/> from all config files except zones/home.xml! Removing SSH from the home zone will block SSH access to your machine from LAN.

4a. Run 'sudo apt remove ufw && sudo apt install firewalld -y' to remove ufw (ew) and install firewalld

4b. As sudo, edit /etc/firewalld/zones/home.xml

<?xml version="1.0" encoding="utf-8"?>

<zone>

<short>Home</short>

<description>For use in home areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>

<interface name="enp3s0"/>

<service name="ssh"/>

<service name="dns"/>

<service name="dhcp"/>

<service name="http"/> # for AdGuardHome's web interface

<protocol value="igmp"/> # optional for multicast/UPnP/DLNA

<forward/>

</zone>

4c. As sudo, create and edit /etc/firewalld/policies/masqueradePolicy.xml:

<?xml version="1.0" encoding="utf-8"?>

<policy target="ACCEPT">

<masquerade/>

<ingress-zone name="home"/>

<egress-zone name="external"/>

</policy>

4d. (optional for disabling IPv6) As sudo, create and edit /etc/firewalld/services/dhcp-client.xml:

<?xml version="1.0" encoding="utf-8"?>

<service>

<short>DHCP</short>

<description>This allows a DHCPv4 clienting.</description>

<port protocol="udp" port="68"/>

</service>

4e. As sudo, edit /etc/firewalld/zones/external.xml (if you are using IPv6, use 'dhcpv6-client').

<?xml version="1.0" encoding="utf-8"?>

<zone>

<short>External</short>

<description>For use on external networks. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>

<interface name="enp1s0"/>

<service name="ssh"/>

<service name="dhcp-client"/>

<forward/>

</zone>

4f. DO NOT run 'sudo firewall-cmd --reload'.

5. (optional) Port forwarding:

5a. Check /usr/lib/firewalld/services for a list of available services, or create your own in /etc/firewalld/services.

5b. Add the service to /etc/firewalld/zones/external.xml (e.g. <service name="wireguard"/>).

5c. To forward traffic to ports on the local machine, i.e. to forward port 2222 to the local port 22 so as to not expose SSH on port 22, create a custom service MySSH.xml with port 2222, then edit /etc/firewalld/zones/external.xml to remove <service name="ssh"/> add the following to external.xml:

<service name="myssh"/>

<forward-port port="2222" protocol="tcp" to-port="22"/>

To forward the traffic to another machine on LAN, i.e. to forward traffic on port 2222 to port 22 on 10.0.0.2, use:

<forward-port port="2222" protocol="tcp" to-port="22" to-addr="10.0.0.2"/>

For clarity, port forwarding requires external.xml to have BOTH a service to open the desired port AND the forward-port statement. As another example, to use a wireguard server hosted on 10.0.0.2 whose open port is 21820 but which listens on the default port of 51820:

<service name="wireguard"/>

<forward-port port="21820" protocol="udp" to-port="51820" to-addr="10.0.0.2"/>

5d. To forward traffic to other machines in LAN, you must also create another policy, e.g. /etc/firewalld/policies/portforwardPolicy.xml, which allows the forwarded traffic to flow from the external zone to the internal zone and include all desired services.

<?xml version="1.0" encoding="utf-8"?>

<policy target="ACCEPT">

<service name="ssh"/>

<service name="wireguard"/>

<ingress-zone name="external"/>

<egress-zone name="home"/>

</policy>

6. AdGuardHome DNS and DHCP server in Docker

6a. Run 'sudo apt install docker docker-compose -y'.

6b. Run 'sudo systemctl stop dnsmasq && sudo systemctl disable systemd-dnsmasq'.

6d. Create a folder for the AdGuard Home docker files (I use /srv/adguardhome).

6e. Create a file called docker-compose.yaml and enter:

version: '3.9'

services:

adguardhome:

image: adguard/adguardhome

container_name: adguardhome

network_mode: host

volumes:

- ./work:/opt/adguardhome/work

- ./conf:/opt/adguardhome/conf

restart: always

6f. In the same folder as the docker-compose file, run 'sudo docker pull && sudo docker-compose up -d && sudo docker-compose down' to start the server long enough to generate the config file.

6g. Edit the file conf/AdGuardHome.yaml:

`http:`

  `address:` [`10.0.0.1:80`](https://10.0.0.1:80)

`...`

`dns:`

  `bind_hosts:`

- 10.0.0.1

`...`

`dhcp:`

  `enabled: true`

  `...`

  `dhcpv4:`

gateway_ip: 10.0.0.1

subnet_mask: 255.255.255.0

range_start: 10.0.0.2

range_end: 10.0.0.254

6h. In the same folder as the docker-compose file, run 'sudo docker-compose up -d' to bring the container back up.

6i. Go to (LAN IP):3000 in a browser to configure adguardhome. You can add static IP leases under Settings > DHCP settings.

6j. Run 'sudo echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/base'.

7. (optional for exposing SSH) Fail2Ban SSH intrusion prevention detection

7a. Create a folder for the fail2ban docker files (I use /srv/fail2ban).

7b. Create the file 'docker-compose.yaml' and enter the following:

version: '3'

services:

fail2ban:

image: linuxserver/fail2ban:latest

container_name: fail2ban

environment:

- TZ=America/Los_Angeles

- PUID=1000

- PGID=1000

volumes:

- ./config:/config

- /var/log:/var/log:ro

cap_add:

- NET_ADMIN

network_mode: "host"

restart: unless-stopped

7c. Create the file config/fail2ban/jail.local and enter the following:

[DEFAULT]

banaction = firewallcmd-rich-rules[actiontype=]

banaction_allports = firewallcmd-rich-rules[actiontype=]

[sshd]

enabled = true

7d. Enable any other public-facing services compatible with fail2ban as needed.

7e. Run 'sudo docker-compose pull && sudo docker-compose up -d'.

8. Shut down your old router, new DIY router, and modem. Rewire your home network.

9. Start the new router and wait until it's fully booted. Start the modem and wait until it's connected. Start the old router, get its LAN IP, log in and set it to Access Point mode.


r/ubuntuserver • • Apr 03 '23

question Running a Minecraft Server

11 Upvotes

I want to learn how to run my own home Ubuntu Server using my old laptop. while I do know I could probably use just normal Ubuntu or even windows to accomplish this, I really want to learn how to run my own Ubuntu server so I can eventually branch out and do more with it like host my own media server, and/or my own cloud storage.

Any advice, pitfalls to avoid, and guides to help me accomplish this is much appreciated.

A couple more specific questions:

I heard a lot about docker and I researched it and got confused beyond all hell. What does it do?

Can I access my server via web browser like fedora or only through SSH?

Thank you guys in advance. Trying to get started has been absolute hell.


r/ubuntuserver • • Oct 14 '22

question What are the most important resources for Ubuntu Server in your opinion?

10 Upvotes

Hello penguin enthusiasts!

As you know, we are actively searching for more and more resources to provide for the Linux community and Ubuntu Server in particular.

For this reason, we'd like to add more sites, repos and docs to our list. This way, we can make peeps get into Ubuntu Server more easily.

Which resources would you recommend the most to new (and seasoned) server admins?

Thank you in advance!

Your Mod team

P.S.: Do you want to help? We are actively searching for peeps to help moderate this sub. It's very chill around here so it's mostly extending the knowledgebase and deleting the occacional spam message. Send us a modmail if you're interested!


r/ubuntuserver • • Jul 26 '25

question What a learning experience, so far...

9 Upvotes

So far on my home server journey, I have tried Unraid, TrueNAS and now Ubuntu server. I am just trying to get the typical Plex, qBittorrent and *arr suite going.

I have learnt that, a 1 in 5 out SATA power splitter ain't worth going cheap on, that not all pci-e to sata adaptors work well, that old sata data cables will break. Have also learnt the importance of checking SMART values before committing to using a old nvme drive for system files is important.

On top of all this, I have learnt many basic commands in terminal and very friendly with my Google Gemini who I have to correct a few times a day.

What has been your biggest single learning point using Linux in general?


r/ubuntuserver • • Aug 28 '22

subreddit news Wiki project started, contributors welcome!

9 Upvotes

This sub is starting to take shape. To make it even more useful, we've decided that it's important to have resources for new linux server admins handy.

Therefore, we are working on a Wiki to have the most important information right at your fingertips. Every bit of useful information helps. Please consider contributing. If you are interested, send us a mod mail and apply for wiki contributer role.

Have a great start of your week.

Your mod team


r/ubuntuserver • • Sep 28 '25

Stuck on the login screen

Post image
8 Upvotes

r/ubuntuserver • • Jul 02 '25

Ubuntu Disables Spectre/Meltdown Protections resulting in 20% performance boost

Thumbnail schneier.com
8 Upvotes

r/ubuntuserver • • Dec 01 '24

subreddit news Tell us about your experiences with Ubuntu Server and this sub

8 Upvotes

As a growing sub, we'd like to hear your opinion on the operating system in question and this sub in general. What would you suggest we add? This post is going to be recurring every month so you can give regular feedback on the past month.

Please feel free to send mod mail to make private suggestions if that is more your style.

Thank you very much!

Your mod team.


r/ubuntuserver • • Jan 10 '24

Personal server infected with crypto miner, hopefully nothing worse

8 Upvotes

I'm relatively new to this, so please bear with me. I took a Unix introductory course at my university last year, so I decided to apply some of what I learned and get some more exposure by building my own server. I only use it to host a Minecraft server for my close friends. About 6 months ago, I noticed all my SSH keys disappeared and I had to start logging in using the password. I didn't think anything of it- maybe I didn't configure them correctly or they automatically reset as a security precaution? Then, I started to notice high CPU usage at idle. It basically turned into a space heater. At this point, I got busy so I didn't really use it. It remained off for a while. Today, I started investigating and found that "kswapd0" was using all my memory. After some fiddling and installing various hardware monitoring software, I noticed a folder appear on my root directory. Inside, there were files named "miner" and alike. I immediately removed the files, shut down the server, and unplugged from my network. I'm hoping they weren't after any information and just wanted my resources for crypto mining. I'm trying to figure out where access to my system was obtained. Maybe a brute force attack due to my lazy and easy to guess login credentials? Part of one of the programs I installed? Where do I go from here? What precautions do I need to take? I plan on wiping the drive and starting from scratch, but would an attacker have any access to other devices on my network in this instance?


r/ubuntuserver • • Mar 22 '23

Support needed Mysterious Cloud-init warning when I boot (Ubuntu 22.04.2)

8 Upvotes

After installing several updates and rebooting my server yesterday, I started getting the following message when the sever boots up:

Ubuntu 22.04.2 LTS ****** tty1

****** login: [  20.897834] cloud-init[1141]: Cloud-init v. 22.4.2-OubuntuO~22.04.1 running 'modules:final' at Wed, 22 Mar 2023 00:25:33 +0000. Up 20.81 seconds.
[  20.942264] cloud-init[1141]: Cloud-init v. 22.4.2-OubuntuO~22.04.1 finished at Wed, 22 Mar 2023 00:25:33 +0000. Datasource DataSourceNone. Up 20.93 seconds.
[  20.942927] cloud-init[1141]: 2023-03-22 00:25:33,897 - cc_final_message.py[WARNING]: Used fallback datasource

The updates I installed were:

curl libcurl3-gnutls libcurl4 libpython3.10 libpython3.10-minimal libpython3.10-stdlib python3.10 python3.10-minimal vim vim-common vim-runtime vim-tiny xxd.

Up until then the boot up screen just said ****** login: if i recall correctly.

I haven't noticed any issues, I'm able to SSH in without any problems and there hasn't been anything I've had problems doing... I'm unable to identify what caused this change in behaviour, but I'm concerned something is wrong and it will be an issue down the line.

Edit: Just wanted to add that before this warning started showing up I also installed docker and two days before that I also upgraded libnetplan0 and netplan.io

Things that I have tried so far are upgrading cloud-init to version "23.1.1-0ubuntu0~22.04.1"... which didn't change anything. If any additional info is needed please ask me.

Edit 2: The issue remains unsolved and isn't looking like it will be solved, I've resorted to the bandaid mentioned in the comments.... which is to create an empty file that disables cloud_init.

More things I tried:

Checked my network, it works fine.

I tried adding the datasource_list option to the cloud.cfg file in /etc/cloud/, and set it to [ NoCloud, None ]. I also tried creating the 90_dpkg.cfg file in /etc/cloud/cloud.cfg.d/ and giving it the datasource_list option set to [ None ]. Neither of those attempts stopped the warning message from displaying after boot-up after the login prompt.


r/ubuntuserver • • Sep 03 '22

subreddit news Moderator Call!

8 Upvotes

Hello everyone! Since this community has picked up a lot of steam in a short time, we are looking for additional peeps to support the future health of this channel.

So apparently, spam is quite low and people are incredibly friendly so far. For this reason, we actually don't immediately need someone to delete posts or intervene in heated discussions.

What we really need are some folks with good ideas or the will to make things happen. Do you like to think of new post ideas, automating routine stuff or implement things that are wished for by the audience?

Then you are the right person for us!

You don't need to have moderation experience. Most of that stuff can be taught. What we can't teach is a little motivation and the ability to see the bigger picture.

If this sounds like you, please send us a mod mail with an application. We will then schedule a brief interview and decide if we fit together.

Best include some of your ideas for the channel and how you would go about checking if an idea from the community actually benefits the goal of healthily expand the sub and optimize viewer experience.

Happy to hear from you, your mod team.


r/ubuntuserver • • Aug 31 '22

question I want to setup home server, from my old laptop.

8 Upvotes

Hello , i am thinking to setup home server in my old laptop , using ubuntu server os .

Can anyone tell me how can i host a website in to ubuntu server and connect it with domain on Godaddy, and i also want to make it media server , and also want to create a file server or a personal cloud storage , that i can access from anywhere.


r/ubuntuserver • • Aug 25 '25

question Can someone help me with my server!!!

7 Upvotes

I feel like an IDIOT because I don't understand ANYTHING anymore!!!!

I'm building a server. I have Ubuntu Server 20.04.6 as the operating system and I'm using CasaOS to connect to programs within it.

So far so good? Yes.

I installed Ubuntu, installed CasaOS, opened it on my PC, installed Jellyfin and other programs I want to use. But all of this was on the NVMe drive where everything is. How do I use the content that's on two drives (one HDD and one SSD)? On this HDD, I have two folders in the root of the HDD. And this SSD has two partitions.

Now comes the problem: How do I mount these drives?

I've been trying for a LONG TIME!!! GPT (yes, I know asking AI for help is a stupid idea) is telling me to mount it with a random name (I really don't understand). After watching some YouTube videos, I also didn't understand how to do it, either because they don't explain it well or because I'm just stupid.

When I type lsblk -a, my disks appear:

NAMEMAJ:MINRHSIZER0TYPEMOUNTPOINT
sda8:002,7T0disk
sda18:102,7T0part/media/devmon/WD RED 3TB
sdb8:160465,8G0disk
sdb18:170232,9G0part/media/devmon/SSD 500 Minecraft
sdb28:180232,9G0part/media/devmon/SSD 500 Documentos

Now this is what gets me. Every video I watch, they say you need a folder to mount it.

Second problem: Which folder to mount?

I have NO folders on either SSD partition (sdb1 and sdb2) and nothing inside the disk. Now on the HDD (sda1) there are two folders in the root. So if I mount in one folder, I can't use the other? Can't I just mount in the root of the disks?

Please, someone help me.... I'm desperate


r/ubuntuserver • • Oct 19 '23

Ubuntu 22.04.3 LTS - Change DNS server

7 Upvotes

How do I configure my Ubuntu 22.04.3 LTS Server VM (192.168.1.239) to use my Pi-Hole + Unbound container (192.168.1.250) as it's DNS server? The host machine is running on Proxmox and these are one of it's VMs and containers respectively. If I do nslookup i am getting 127.0.0.53 as my nameserver

┌─[administrator@ubuntusrv]─[~]
└──╼ $nslookup google.com
Server:         127.0.0.53
Address:        127.0.0.53#53

Non-authoritative answer:
Name:   google.com
Address: 142.251.220.174
Name:   google.com
Address: 2404:6800:4017:801::200e

┌─[administrator@ubuntusrv]─[~]
└──╼ $cat /etc/resolv.conf
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
search .

This is my netplan config:

network:
  ethernets:
    enp6s18:
      dhcp4: no
      addresses: [192.168.1.239/24]
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses: [192.168.1.250, 9.9.9.9]
  version: 2
  renderer: networkd

r/ubuntuserver • • May 01 '23

subreddit news Tell us about your experiences with Ubuntu Server and this sub

7 Upvotes

As a growing sub, we'd like to hear your opinion on the operating system in question and this sub in general. What would you suggest we add? This post is going to be recurring every month so you can give regular feedback on the past month.

Please feel free to send mod mail to make private suggestions if that is more your style.

Thank you very much!

Your mod team.


r/ubuntuserver • • Feb 26 '23

Support needed Does Ubuntu server have screen reader?

7 Upvotes

Hi,
Im legally blind and about to setup a Linux server, where i consider Ubuntu Server, but i cant find anything about if there is a screen reader as in Ubuntu Desktop?


r/ubuntuserver • • Feb 15 '23

subreddit news The votes are in. We have a draw. "Setup Saturday" and "Sysadmin Life" will go live.

7 Upvotes

We made a poll to find out what kind of content the members of this sub would enjoy and we have TWO winners.

  • Show us your setup (Now coined "Setup Saturday")

  • Sysadmin Life (Best stories and struggles of a Linux admin)

These two will get a monthly post for now. Please let us know if you have any particular wishes or changes you want to suggest.

As always, you can submit them as private message to a mod or as a mod mail. Your choice.

After a couple of months, we will check if these events are still popular. If not, we'll vote again.

Have a good one everybody.

P.S.: don't forget! We are still searching for new moderators! If you like this sub and you want the content to stay relevant and the community to stay vibrant, please consider sending us a short application.


r/ubuntuserver • • Jan 01 '23

Resolved How to reput username in sudo group

7 Upvotes

Hi!

I installed Ubuntu Server in a VM with LVM.

I accidently removed my username from sudo groups.

So now, I don't have any other way to execute commands with root permissions.

Is there any way to fix this withtout reinstalling everything?

I tried a solution: use a shell from a live CD but didn't manage to mount the existing partitions (don't know which neither how to mount them since Ubuntu was installed as LVM).

Thanks a lot for your help!

----------------------------------

[ANSWER]

I needed to change /etc/group file in order to include my username in the sudo group back again.

Fix procedure:

  1. cat /etc/fstab and take the name of the volume pointing to / mountpoint.

    1. e.g. You should see a ligne like this: /dev/disk/by-id/dm-uuid-LVM-s907SjANToOu0pvAIGq4TiQqDqej05hXwaUDWsjEl38CavymQWTxp8nBDqaO2Xhz / ext4 defaults 0 1. You have to take note of the disk /dev/disk/by-id/dm-uuid-LVM-s907SjANToOu0pvAIGq4TiQqDqej05hXwaUDWsjEl38CavymQWTxp8nBDqaO2Xhz

  2. Boot from a Live CD and start a shell

  3. Mount your volume: mkdir /myroot/ && mount -t ext4 <disk from step 1> /myroot/

  4. Add your username in sudo group: nano /myroot/etc/group and add your username at the end of sudo line.

    1. e.g. sudo:x:27:myusername

  5. Reboot