Alternative ssh identity files with drush aliases

Posted on September 19, 2010 at 12:00 pm

I’ve now started to use drush almost exlusively to manage our Drupal instances. If you’re not familiar with drush it provides an excellent command line interface to Drupal.

One of the most powerful features in drush is site aliases. This allows you to setup shortcuts to your dev, staging and live servers. Once you’ve setup the aliases (see below), you can simply reference any of you servers with the @alias. For example, I’ve setup an alias to dev.begrand.net, so I can simply issue any drush command with @dev.begrand.net, for example:
[sql]drush @dev.begrand.net st[/sql]
from my staging server and see what the status of my dev server is – which is nice. All drush commands accept the alias, so it saves a lot of time because I don’t have to ssh into each server as needed.

Creating an alias

In order to setup an alias, you need to be in the drush installation directory (mine is installed in ~/drush and symbolically linked to /usr/local/sbin, but yours may vary). Once there, create a new file called sitename.alias.drushrc.php (where sitename is the alias you want to use, in my case it’s dev.begrand.net so the full filename is dev.begrand.net.alias.drushrc.php).

The contents of the file should look like this:

[php]
<?php
$aliases['dev.begrand.net'] = array (
‘root’ => ‘/var/www’,
‘uri’ => ‘dev.begrand.net’,
‘remote-host’ => ‘dev.begrand.net’,
‘remote-user’ => ‘devuser’
);
?>
[/php]

So far so good, but I’m using Amazon EC2, which relies of certificate-based ssh authentication. We use a non-standard name for our certificate files as well, so I needed a way of specifying the identity file for drush to use. In my case, the pem file is called dev.pem and is installed in the .ssh directory in my home directory (so ~/.ssh/dev.pem).

After a bit of searching around, I found the answer; it’s very very simple.

All I had to do was add and ‘ssh-options’ parameter to the aliases array, so my final sitename.alias.drushrc.php looked like this:

[php]
<?php
$aliases['dev.begrand.net'] = array (
‘root’ => ‘/var/www’,
‘uri’ => ‘dev.begrand.net’,
‘remote-host’ => ‘dev.begrand.net’,
‘remote-user’ => ‘devuser’,
‘ssh-options’ => ‘-i ~/.ssh/dev.pem’
);
?>
[/php]

Job done! The more I use drush, the more I love it!

Tags: , ,

14 Responses to “Alternative ssh identity files with drush aliases”

 
  1. [...] Alternative ssh identity files with drush aliases « SlashZero Limited [...]

  2. AKO WEBMAIL says:

    creighton lane flan porn cabbages orio blomfield anything doda

  3. The newsreader would present to camera while sitting on the edge of a desk behind him staff would be seen working busily at their desks.

  4. Backlinks says:

    Check out this crazy service that sends thousands of visitors to your web page automatically!

    Hey slashzero.co.uk admin

    I wanted to tell you about this website I used with great results, that drives thousands of targeted visitors to your site who are dying to spend money!

    You’ve probably already know that creating great content is only half the battle when it comes to running a successful website. The second half of the equation is DRIVING TRAFFIC!

    With this service, you can forget about the tedious process of posting backlinks because they do everything for you so you can focus on more important things, like dealing with the flood of traffic to your site!

    And that’s not all! this service is SUPER AFFORDABLE and will direct thousands of new visitors to your site in just hours, GUARANTEED!

    This is the only service that can skyrocket your page to the top of the search engines!

    You can check it out here:

    backlink service

    Best,

    Jason

  5. Gabsterz2 says:

    Gabsterz2…

    Great blog post, saw on…

  6. Useful and precise…

    It is incredibly super difficult to find real honest and quality informative and accurate fresh info but today about noon I happily found…

  7. It is really great…

    F*ckin’ amazing things here. I am very satisfied to look your post. Thank you a lot and i am having a look forward to touch you. Will you please drop me a mail?…

  8. Useful and precise…

    Its difficult to find really informative and accurate information but here I found…

  9. Interesting post…

    Usually I don’t learn article on blogs, but I would like to say that this write-up very pressured me to try and do it! Your writing taste has been amazed me. Thanks, very great article….

  10. It is really hard these days to find enough support…

    My friend is truly constantly but in a rash manner proclaiming that in all honesty that it is hard to really easily procure some quality online support, but there is…

  11. Hard Day…

    It was a hard day here today, so I just took to messing around on the internet and found…

  12. I just want to tell you that I am just very new to blogs and definitely enjoyed your web-site. Almost certainly I’m planning to bookmark your site . You actually come with terrific well written articles. Thank you for sharing your blog.

  13. Mustanen says:

    Last Additions on subject….

    [...]Must read if you are interested in what others think.[...]…

  14. Ought says:

    Recommended resource in same niche….

    [...]Informative data analysis. Knowlegable sights. Worth checking.[...]…

 

Leave a Reply