Install Webmin on Ubuntu 12.04 Server

Playing with Linux Ubuntu servers both as virtual machines on ESXi at home and as Amazon EC2 instances requires some administration. Since I have a hard time remembering all the commands I frequently need to use, I like to have Webmin installed to make the administration process much easier. Thankfully, there are repositories available to make installation pretty easy.

Typically adding software repositories is as simple as adding lines to the file /etc/apt/sources.list. However, since Amazon will, under certain circumstances, overwrite this file, it is advisable to create source files in /etc/apt/sources.list.d/. So long as the files end with sources.list, apt will read the sources just as if they were part of the original sources.list file. For instance, when adding Webmin I create a new file called webmin.sources.list in the /etc/apt/sources.list.d/ directory using Nano.

sudo nano /etc/apt/sources.list.d/webmin.sources.list

Once in Nano, I add three lines. The first is a simple comment and the other two are software repositories for Webmin.

# webmin software repositories
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

Exiting Nano to save the file is as simple as pressing Ctrl+X to save and enter to confirm saving the file into the specified location. Although the repository locations will now be read by apt, they will not be used since apt does not have the key yet. Before installing Webmin, the key must be imported for these new repositories.

curl http://www.webmin.com/jcameron-key.asc | sudo apt-key add -

Now apt will read the repositories, so tell it to.

sudo apt-get update

Finally, Webmin can be installed.

sudo apt-get install webmin

Now the server can be administered using any login with sudo privileges at https://<servername or ip>:10000. Remember to use https instead of http and to hit port 10000. If you are running the server locally, you are done. However, if you are setting this up on an Amazon EC2 instance, you still have another step.

If spooling up an Amazon EC2 instance, the root user obviously does not have a login. When connecting to the instance via Putty or Amazon's SSH Java command line client, authentication is accomplished using an authorization file. This means there are no user logins with sudo privileges on the server with a password.

One solution is to simply create a user in the sudo group with a password. This is easily accomplished with the useradd command. The usera command takes the form of useradd -g <group> <username>. Thus, adding a user named webmin to the sudo group can be accomplished by...

sudo useradd -g sudo webmin

The new user webmin needs a password. Assign one using.

sudo passwd webmin

Now just login to Webmin using this user. You are good to go!