29 - June - 2011

Gaining access to a Drupal website using Drush

Post by Peter L

This is handy for Drupal admins or support staff doing migrations who have no current administration access to a site.

You will need SSH access and drush installed on the server.

The adminrole module (No Drupal 7 version available) is required so download and enable this as follows (replacing the path to your Drupal site installation as necessary):

cd /var/www/vhosts/drupal
drush dl adminrole
drush en adminrole

The adminrole module creates a new 'administrator' role on your Drupal site and automatically ticks all permissions for any modules added to your site. This ensures any user who is assigned the role of 'administrator' will have the best possible access to the site administration.

We can use the drush ucrt command to create a user. As with a normal Drupal user account this requires a valid email address to be supplied. In our example we will create a new user account for 'norman'.

drush ucrt norman --mail='norman@ixis.co.uk'

drush urol is then used to give the above user admin access

drush urol administrator norman

followed by executing drush uli which emails the above address a one time URL to allow user to login and create a password.

drush uli norman

Check your email inbox and click the link and you'll now have administrator access to the website without having to change the password for user 1 in via the database.

Remember: Watchdog records every user who logs in to a Drupal site - so ensure you have permissions to access the site in question before doing any of the above steps.

Add new comment

Share this article

Sign up to our newsletter!

Our thoughts

Let's work together

Get in touch and find out how we can empower your organisation.
Back to top