Hacking your way to root on FreeBSD in Azure

UPDATE 19/06/2016: Apparently the root user is disabled on Linux virtual machines in Azure, so the guidance is to use sudo to run commands with elevated privileges. So the below post is somewhat irrelevant, but if you still want to log in as the root  user then it’s still valid. Or you can obtain a root shell using “sudo -s”. Fore more information about the documented way to do this I have been directed to a couple of articles by Microsoft support: Introduction to Linux on Azure, and Using root privileges on Linux virtual machines in Azure. I wouldn’t have found them anyway because FreeBSD isn’t Linux. 🙂


Back in the early to mid 90’s before I discovered Windows NT and changed the focus of my career, I spent a lot of time playing around with FreeBSD, OpenBSD, Redhat, and even Solaris. Let’s just say that CLI was and still is my friend (I still run a Cisco 867 router at home).

As much as I love spinning up Windows servers and desktops in Azure for labs and tests, I’d never really had a reason to fire up a Linux or Unix server. That changed when my old favourite FreeBSD was launched on the Azure Marketplace.

So I spun up a FreeBSD instance using the low-cost A0 instance as I still didn’t know what I was going to do with the server (and it’s been about 15 years since I’ve used it – so my skills are a little rusty).

When provisioning the server, you’re asked to specify a username, but upon logging in to the server I found that I was just a mere mortal – incapable of switching to the root user:

Unfortunately, the documentation on working with FreeBSD in Azure is lacking. Looking at an old blog from 2014 about running FreeBSD in Azure it indicated that you could log into root with no password – which seemed highly unlikely for a terminal session across the Internet. I gave it a try anyway and got this:

What I did find was that apparently I could create a new user with sudo privileges from within the Azure portal:

Looking at the article about how to reset access in Linux virtual machines on Azure under the section Create a new sudo user account I wasn’t much more enlightened.

I thought I’d give it a crack anyway and created an account called sudouser with a new password. Lo and behold it worked!

My next step was to then make my original account a member of the “wheel” group:

Great, that’s done. Now let’s try to su to root again:

Oh that’s right, I don’t know the password for the root account.

Back to our sudo user to reset the password:

Ok, password is set, let’s try again:

Time to strap on my rollerblades and HACK THE PLANET!!!



P.S. It’s quite possible that my original account could have executed the sudo commands as necessary, but I didn’t test it while figuring this out – so I welcome anyone to test it themselves and give me some feedback.

1 comment

  1. I hit the same issue, but ended up doing ‘sudo sh’ which dumped me straight into a root shell. Glad to have found your article – running FreeBSD in Azure feels a bit lonely sometimes, am not sure if anyone else is actually dong it!

    BTW, BSD has come a very long way in the last 15 years (and I;ve been using it since about 1988, the last few years have ben the biggest changes ever).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.