I recently installed a fresh copy of Ubuntu Server in a VMware Fusion virtual machine, so I could test some things out locally. (It’s a great way to set up a local development server with a similar configuration to your production server.) The initial setup was painless, but I had an amusing problem after. The default keyboard mapping didn’t match up with my MacBook’s keyboard, so pressing the arrow keys would lead to unexpected behavior. Obviously this is problematic behavior when the only way you have to interact with the OS is text-based…
Fortunately, the solution is simple.
You just need to run sudo dpkg-reconfigure console-setup
and follow the on-screen prompts. You would usually use the arrow keys to traverse the menus, but that isn’t exactly possible, is it? Pressing the first letter of the option you’re looking for until it cycles up and is selected works fine, though. (Apple Laptop, USA-style layout, etc.) The full instructions on what you should pick for MacBooks are available here.
Now, moving in and out of the VM window is a little bit annoying, so I installed an SSH server.
sudo apt-get install openssh-server
Easy enough. Now you can SSH into the server from a native Terminal session, which is easier to Command+Tab in and out of, and you can make use of the clipboard. Not being able to copy and paste sure is limiting.
Now you only have one final obstacle standing between you and easily connecting to the server. Whether you’re using SSH or accessing a web page being served by the VM, you need to figure out the local IP address of the VM on the network and input that. Or you can set up ZeroConf, which lets other machines on the network automagically find the VM when you call it by name. Instead of addressing it as 192.168.0.255
, you could use Ubuntu.local
. (Very handy when you’re running game servers on your LAN.)
The following command will install the required packages to enable ZeroConf on the VM.
sudo apt-get install avahi-daemon avahi-discover avahi-utils libnss-mdns service-discovery-applet mdns-scan
Now you can reach the VM at thehostname.local, which is considerably easier than figuring out what IP your router has assigned it and pasting it in whenever you need it.