? 2011_02_17-support-ssh-options.patch
Index: pushkey.drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush_extras/pushkey.drush.inc,v
retrieving revision 1.4
diff -u -p -r1.4 pushkey.drush.inc
--- pushkey.drush.inc	2 Dec 2010 23:17:44 -0000	1.4
+++ pushkey.drush.inc	17 Feb 2011 07:04:06 -0000
@@ -39,6 +39,7 @@ function pushkey_drush_command() {
     'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, // No bootstrap.
     'options' => array(
       'keyname' => 'Specify which key to use or the name of the key to generate. Defaults to id_rsa.',
+      'ssh-options' => 'Any addition options to pass to ssh. E.G the remote port number.'
     ),
     'arguments' => array(
       'target' => 'The user and machine to push to ("user@machine.com").',
@@ -46,6 +47,7 @@ function pushkey_drush_command() {
     'examples' => array(
       'drush pushkey user@myserver.com' => 'Push your public key to a remote server.',
       'drush pushkey user@myserver.com --keyname=drupal_rsa' => 'Push your public key named drupal_rsa.pub to a remote server.',
+      'drush pushkey user@myserver.com --ssh-options=\"-p 222\"' => 'Push your public key to a remote server where ssh is listening on port 222.',
     ),
   );
 
@@ -122,8 +124,11 @@ function drush_pushkey($target = NULL) {
   // Read in the public key data
   $remote_public_key_file = $local_machine_name . '_' . drush_get_option('keyname', 'id_rsa') . '.pub';
   
+  // ssh options to be prepended
+  $ssh_options = drush_get_option('ssh-options', '');
+  
   // Build the remote command and then run it
-  $exec = "ssh $remote_machine_with_user /bin/sh -c \"'mkdir -p \\\$HOME/.ssh && key=\\\"$public_key_data\\\" && (echo \\\$key > \\\$HOME/.ssh/$remote_public_key_file) && (cat \\\$HOME/.ssh/$remote_public_key_file >> \\\$HOME/.ssh/authorized_keys) && chmod 600 \\\$HOME/.ssh/authorized_keys'\"";
+  $exec = "ssh $ssh_options $remote_machine_with_user /bin/sh -c \"'mkdir -p \\\$HOME/.ssh && key=\\\"$public_key_data\\\" && (echo \\\$key > \\\$HOME/.ssh/$remote_public_key_file) && (cat \\\$HOME/.ssh/$remote_public_key_file >> \\\$HOME/.ssh/authorized_keys) && chmod 600 \\\$HOME/.ssh/authorized_keys'\"";
   $result = drush_op('system', $exec); 
 }
 
@@ -160,4 +165,3 @@ function drush_extras_parse_target($targ
   }
   
   return array('remote-user' => $remote_user, 'remote-host' => $remote_machine);
-}
