Does anyone know about a good tutorial for remote aliases?

Events happening in the community are now at Drupal community events on www.drupal.org.
betovarg's picture

Hi there,

I understand that you can use drush installed locally, on a remote server without the need to use ssh, through an alias. Is this correct? Do you people know about a good tutorial out there? I have a bluehost account and they ask for some ID faxed to them, I do not live in the US and i dislike the idea of having to scan an send an ID. Not happening.

Thanx in advance!

Comments

I read the chapter about

m_wiking's picture

I read the chapter about Drush in this book: http://definitivedrupal.org/

I don't remember where I found it. But it was really good. It will be released soon so you might want wait for that.

/Mattias

Well, you should reconsider

pgorecki's picture

Well, you should reconsider getting ssh access to your Bluehost account (that's what I did, I'm non-US citizen too). By enabling ssh access to BH you can install git there and have your own repositories for drupal projects. Moreover, you must have ssh to use drush remotely (preferably with passwordless login). That makes moving from dev to staging much much easier.

Thanx for the suggestion, I'm

betovarg's picture

Thanx for the suggestion, I'm still not very convinced of the fact that i have to give away my id... there are hosts that don't require that! Anyway, if there is a way to do that with drush I would like to know more. Thanx!

You need SSH access to use

pgorecki's picture

You need SSH access to use drush on a remote site. In addition, I assume the following:
- remote machine is remote.example.com
- remote user name is "remoteuser"
- you can login to a remote server via ssh (by typing ssh remoteuser@remote.example.com). For your convenience you can set up a passwordless login to a remote server by typing the following commands on your local machine:

ssh-keygen -t rsa  //this will generate a pair of private/public keys needed for passwordless login
ssh-copy-id remoteuser@remote.example.com //after typing the password, you should log out from remote machine
//this time ssh remoteuser@remote.example.com will not prompt for password

- your local site is in this directory on your local machine: /home/localuser/www/drupal
- your remote site is in this directory on your remote machine: /home/remoteuser/www/drupal
- you have drush installed both on local and remote machine
- settings.php for both sites in sites/default directory

You want to invoke drush commands from your local machine, so you must add drupal.aliases.drushrc.php file to /home/localuser/.drush on your local machine. In this file add the following to create aliases for both sites:

<?php
$aliases
['drupal.local'] = array(
 
'root' => '/home/localuser/www/drupal',
 
'uri' => 'default',
 
'path-aliases' => array(
   
'%files' => 'sites/default/files',
   
'%dump'  => '/tmp/drush-sql-sync-ast.sql',
  ),
);
$aliases['drupal.remote'] = array(
 
'root' => '/home/localuser/www/drupal',
 
'uri' => 'default',
 
'remote-host' => 'remote.example.com',
 
'remote-user' => 'remoteuser',
 
'path-aliases' => array(
   
'%files' => 'sites/default/files',
   
'%dump'  => '/tmp/drush-sql-sync-ast.sql',
  ),
);
?>

now on you local machine you should be able to do the basic "status" command:
drush @drupal.local status
drush @drupal.remote status

And that's it for setting up drush.

SSH Help

tigron's picture

I could use a little help with this, I had a SSH key setup using putty. I was trying to set this up and now I have replaced the key on my server with putty and it's acting like I'm trying to login to gmail. I think I know the answer but for clarity can you tell me how I should set this properly where I can do this locally and use putty ?

Thank you, I think i was

betovarg's picture

Thank you,
I think i was confused with the sync action. You cannot use drush on a server without the ssh access.

Thanx again you all.

A couple of useful tutorials

jrsinclair's picture

The information provided by @pgorecki is a great start and all true. If you're looking for more information on aliases, the best resource I've found is Simon Hobbs' emspace article: http://emspace.com.au/article/drush-aliases-primer-live-dev-syncing

If you're after information on Drush in general, I've written a introduction at: http://www.opc.com.au/web-development/introduction-drush-drupal-power-tool

I hope they might be helpful to someone.

Indeed. Thank you all very

betovarg's picture

Indeed.

Thank you all very much!

Cheers

dddbbb's picture

All very helpful stuff here. Thanks folks.

drush

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: