Remote Linux Admin for Windows Users
By
All the cool kids in the web world these days seem to be using Macs, which have hearts of Unix so are natural complements to Linux-based servers. Others are running Linux desktops. So a lot of the remote server administration information on the web assumes that you’re on either a Mac or a Linux box.
For historical reasons, however, I have a collection of Windows systems, and they’re what I’m comfortable with. I also have some things, like my collection of 60,000 photos managed in the Photoshop Elements Organizer, that aren’t easily moved to a Mac, and I have lots of Windows applications that I own and am familiar with. So while I don’t have any religious feelings about it (please, spare me the Mac evangelism), I’m using Windows systems to remotely administer my web servers.
This really isn’t a problem, as there are ample tools available to make Windows do most everything a Linux system does, or a least everything you need to do to administer one remotely. But it does take a little more effort, at times, to track down the right tools and figure out how to apply them. If you’re early in this process, this article may help. (If, on the other hand, you’re a grey-beard Linux hacker or a Mac die-hard, you can stop reading now.)
Although there are GUI interfaces for Linux, remote administration is done predominantly from the command line. And if you want to follow the well-greased paths for deploying Rails applications, you’re going to be living in a command-line world. This is, of course, rather alien in the Windows environment.
There’s really two command-line environments you need to use: the Windows command shell, for taking actions on your local machine, and a Linux shell, for interacting directly with your server. The Windows shell is essentially a grown-up version of the old DOS prompt. Linux shells come in a variety of versions, with BASH being the most common.
Enhancing the Windows Command Window
You need to use the Windows shell to control your local development environment, and with some extensions (to be described in a later post), you can use it for some tasks that involve your remote server as well.
To open a Windows command shell, you can select Run from Start menu and then enter cmd and click OK. But there’s a better way: Microsoft offers a free add-on that lets you open a command window by right-clicking on any folder and choosing a new option that the add-on installs, “Open Command Window Here.” Aside from being quicker than the Start > Run > cmd approach, it opens the command window with the current directory set to the folder upon which you right clicked. Download the command window PowerToy. It is entirely painless and will make your life just a little bit simpler.
Now you should customize your command window settings, as the defaults are pathetic. The window has no menu, so it may not be immediately clear how one customizes it. The secret is to open any command window, right-click on the title bar, and choose Properties. Once in the properties dialog, here’s some things you might want to change:
- In the Options tab, check the boxes to enable Quick Edit Mode and Insert Mode. This enables you to cut and paste text (you can’t use ctrl-X and ctrl-V like you can in a GUI environment). To copy, select the text and then click the right mouse button. To paste, just click the right mouse button.
- Also in the Options tab, change the Buffer Size to 999, and the Number of Buffers to 5. This gives you more memory for past commands. At any command prompt, press the up arrow repeatedly to move back through previous commands. This can save a lot of typing.
- In the Layout tab, increase the Screen Buffer Height to 2500, so you’ll have more text you can scroll back through after it scrolls off the top of the window. Increase the Screen Height to provide a window as tall as you’d like; I prefer 75 for my 1200-pixel-high monitors.
- In the Colors tab, change the text and background colors if you’d like. White text on a black background is traditional and has a retro appeal, but I prefer black text on a white background.
When you’re done making changes, click OK, and then choose Save Properties for Future Windows in the dialog that appears. Now you’ll have a much nicer command window to work with from now on.
Get Set up for SSH
Although you can use the Windows command prompt to act upon your remote server, the primary method used to access Linux systems remotely is SSH (Secure Shell). There’s not an SSH client built in to Windows, but good free clients are available. The most popular is PuTTY. Download the PuTTY installer package. Choose the download labeled “A Windows installer for everything except PuTTYtel”, which will get you the complete set of PuTTY utilities, some of which you’ll want later.
Run PuTTY, and you’ll see a deceptively simple window. There’s actually lots of options here, which you can explore by clicking the categories on the left. But you can get started by using all the defaults and simply entering the name of your host (or its IP address) in the Host Name field and clicking Open. (To save yourself a little typing in the future, you can enter a name under Saved Sessions and click Save, and then the next time you can just double-click this name in the Saved Sessions list.)
Assuming PuTTY is able to connect to your host, you’ll then see another of those lovely white text on a black background windows (you can change these settings in the initial PuTTY dialog), with a Login: prompt. At this prompt, enter the user name your host assigned you, and then you’ll get a password prompt. Enter the correct password, and you’ll be online talking to your server, with essentially all the control that a user sitting at the machine has. All data sent back and forth is securely encrypted, so no one will be able to sniff your network traffic and figure out how to get into your server (unlike FTP, in which not only your files but also your user name and password are sent in clear text).
If you aren’t able to connect to your server (even to the point of getting a Login prompt), then check the following:
- Make sure your host has enabled SSH access. If you have a shared hosting account, it might not be offered, or you might have to ask for it.
- Make sure you have the host name right. This should be simply the domain of your web site. If it is a new account and you haven’t set the DNS yet, you can use the IP address.
- If all else fails, check with your host to see if they’ve moved SSH to a port other than the standard 22. Some companies are doing this to reduce brute-force attacks. You can enter any port number in the PuTTY dialog.
If, on the other hand, you get the login prompt but it doesn’t accept your user name or password, double-check that you have these exactly correct. For some hosts, you may need to use “name@domain.com” and not just “name” for your login name. Check the signup material you received when you opened the hosting account.
Once you have these two command-line environments in place, you have the essential tools to both control your local development environment and to administer your server. Now you just need to know what to type into these windows :-).
For more information:
- Excellent overview of SSH software for Windows
- Windows Command Shell Overview
- Complete (though badly presented) Windows Command Reference
- A good third-party Windows command line reference
- Cygwin is a Linux-like environment for Windows…
- Windows Services for Unix contained an emulation environment and useful tools. (Deprecated but might be useful.)
Join Our List
And we'll let you know when we post major new site updates.
We’ll never share your email address with anyone else.
Related Content
from around the Web
Other Articles
- Scale rails from one box to three, four and five
- Putting the pane back into deployment
- Rotating Rails Log Files
- Economical Use of Amazon S3 with Ruby on Rails
- RightScale: Launch your Rails App in minutes on Amazon EC2 using RightScale
- Maintainable Software: Rails Logging Tips
Screencasts
- Phusion Passenger
- Passenger in Development
- Capistrano Concepts
- Railscasts - Filtering Sensitive Logs
Documentation
- Mongrel
- Emiller's Guide to Nginx Module Development
- Robby on Rails : Installing Ruby on Rails and PostgreSQL on OS X, Third Edition
- Phusion Passenger User's Guide
- Apache 2.2 Documentation
- Rails Playground
This article is licensed under a Creative Commons Attribution-NoDerivs 3.0 License