Ubuntu SSH for Software Development

I did a test recently. I wanted to see how quickly I can get a full software development environment back up and running following a systems crash or a reformat. The following are the basics.

KVM/Qemu as the VM technology.

Virtual Machine Manager

Ubuntu 14.04 LTS setup in a virtual machine with a full software development stack.

The main operating system running the virtual machine does not have to be Ubuntu. Sometimes that is better as it can simplify things. Such is the case when the main operating system has a good technical profile for running virtual machines.

Backup the .img files stored in /var/lib/libvirt/images to an external hard drive with plenty of space.

Make sure the files are committed. You can run the sync command, reboot and double-check.

Wipe the main operating system after you have backed up your files, verified the backup.

Now comes the interesting part. Getting to the point where we can simply pickup where we left things in the software development environment since the last time we used it. First, the main operating system needs to be installed.

When installing the main operating system, do a quick install. Should take no more than 10 minutes.

Once you are in the native environment, install KVM/Qemu and Virtual Machine Manager.

Copy the .img files you backed up into /var/lib/libvirt/images or any other storage pool location you setup.

Open Virtual Machine Manager. If you are prompted to install additional modules, do so and then reboot afterwards.

Create a new virtual machine in Virtual Machine Manager or command-line and import a .img file of your choice.

Between the time you reinstalled the main operating system and got back to the virtual machine should be about 20 minutes.

That was the preliminary conditions. The next step is to improve the productive use of the virtual machine. You want to setup two things for that to happen.

Setup ttyS0 in the virtual machine so you can use virsh console name_of_your_machine to get a direct command-line connection. This can be very helpful for troubleshooting or quick execution of commands in the virtual machine without depending entirely on a GUI screen. There are many helpful guides on the Web for setting up ttyS0 for virtual console.

Setup SSH. This is a very important step. While serial console is good, it is limited in the amount of text it can show on the screen. If you need to use vi, emacs, or nano to edit a large file spanning many lines with long line lengths, serial console through KVM/Qemu is not as productive. SSH works much better and is a full featured way to connect to a virtual machine over command line.

Out of the box, you may have problems connecting to a virtual machine over SSH. Some issues may depend on how your virtual machine is set up. In my case, I have an Ubuntu 14.04 LTS virtual machine that has everything I need on it (C++, C, PostgreSQL, Mono, SQLite3, Apache, Clang, and dozens of code libraries). I could not connect over SSH.

After a few days of trying several things, I was hitting a wall. The last time I used SSH was 2005. Anyway, I came upon a guide from the Ubuntu website about the SSH Configuration. Although I had followed other directions from a separate article from the website, I was running into issues. It seems restarting the ssh process, then logging in local triggered a configuration. The point is, SSH to a virtual machine does work and is a good way to gain productive use of the technology.

The process described in this article is a good way to have a clean host operating system with just the tools you need. As long as you keep a current backup of the .img file that describes each virtual machine, you will have the ability to get back up an running following a crash or a need to reinstall a system. I have tested this process a few times, but the SSH scenario only once. Since I made no configuration changes to the main operating system, I am satisfied that SSH works out of the box with a sufficiently well configured virtual machine.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s