When starting to develop a new Drupal site, there are a couple of things that you need to do first. You need to log on to your development server, probably done through the command line over SSH, and you need to log on to your site via the browser. My word! Two authentications! Wouldn't it be nice if this dreary, menial task could be accomplished with a spiffy command line tool? What we need is flexible architecture which allows you write your own commands that execute Drupal code. In other words, we need Drush.
If you haven't started writing your own Drush commands yet, now is a great time! A good way to start is to look at the
Drush make-me-a-sandwich command. By leveraging the power of Drush, you can do all kinds of fancy things from the comfort of your own terminal. Here are some interesting ones.
So, back to our login problem! Evolving web has created a Drush command that will allow you log in to your Drupal site as an arbitrary user from the command line. It's called Drush Login Link. To use it, place it in your drush/commands directory. If that doesn't appeal to your sense of decency, the sandwich example has some alternate installation procedures. Once it is installed, you can simply navigate to the site of your choice. Type drush login-link (or drush ll for short), and presto! You now have link you can use to login to your site as an administrator.
There is a catch: Drupal chooses not to store the domain of the site in the database in any place where it can be identified with total certainty. If you have set the $base_url variable in the settings.php file, login-link will use it. Short of that, login-link will attempt to look at recent entries in the watchdog table, and extract the domain from them. If it finds more than one, multiple links will be created for your clicking pleasure. If there are no links (for example, if you have recently emptied the table after migrating your site) you could always navigate to a nonexistent url, which will generate a new entry in your watchdog table.
By the way, should you desire to log in to somebody other than user 1, you can also specify a uid or a username:
drush ll 42
drush ll --username dries