Create a Drush alias to connect private Remote IP via ssh

What is Drush ?

Drush is a very cool command line utility to perform actions to your Drupal Application.

Drush is a very good friend of Developer. We can do perform below tasks using Drush:

  • Drush helps to manage Drupal website remotely
  • You can Install/enable module(s) using drush. You don’t need to an FTP client to do this
  • You can clear cache using Drush.
  • Check installed modules/themes, you can disable modules using this
  • Drush Provides easier way to code review and Diffs.
  • Maintaining patches using drush is very easy
  • A drush alias is a shortcut to a remote Drupal application, which can be accessible via tunnel or VPN.

    It’s great, that you found it interesting. To use drush from local machine to your private IP like your private EC2 instance.

    Here i am assuming that Drush is already installed to remote machine (If not follow the same step to configure to remote as well). I am going to explain installation, configuration and uses of drush on your local machine to remote machine.

    Install Drush via composer

    Open terminal and run below command

    curl -sS https://getcomposer.org/installer | php 
    
    mv composer.phar /usr/local/bin/composer
    
    cd ~/
    
    touch .bash_profile
    
    nano .bash_profile
    
    export PATH="$HOME/.composer/vendor/bin:$PATH"
    
    composer global require drush/drush:dev-master
    
    composer global require drush/drush:8.*
    
    

    Now Drush is installed on your machine. Now accessing private ip from your Drush alias. Now we are going to create a drush alias that will connect to your remote IP(via VPN) Assuming you already have VPN access to your remote IP.

    To write a drush alias, Open terminal by default your path will be /Users/username/. Now go to the drush folder. Tupe below command for that.

     cd /Users/kundan/.drush 

    Now you are in your Drush directory. create a new drush alais file. file naming convention will be filename.aliases.drushrc.php. To create a file run below command on terminal

    vim filename.aliases.drushrc.php 
    <?php
      
    #Alias for dev.test.com
    
    $aliases['aliasname'] = array(
      'root' => '/var/www/html/drupal',  //path to remote drupal site
      'uri' => 'dev.test.com',          // URL 
      'remote-user' => 'username',      // ssh username
      'remote-host'=> 'XX.XXX.XX.XXX,   // Your private IP 
      'ssh-options' => '-o PasswordAuthentication=yes'
    );
    
    

    To run this alias, First connect to VPN with your credentials and go to terminal.

    and run

    drush @aliasname status

    It will ask your ssh password and display detail information about your Drupal site.

    In the same way you can run all drush commands. Some are listed below:

    drush @aliasname status
    
    drush @aliasname cc all
    
    drush @aliasname pm-list
    
    drush @aliasname update
    
    

    So all this command is getting execute from local to your remote private Server. You can create multiple drush alias in a single file E.g.

    <?php
      
    #Alias for dev.tes1.com
    
    $aliases['aliasname'] = array(
      'root' => '/var/www/html/drupal',  //path to remote drupal site
      'uri' => 'dev.test.com',          // URL 
      'remote-user' => 'username',      // ssh username
      'remote-host'=> 'XX.XXX.XX.XXX,   // Your private IP 
      'ssh-options' => '-o PasswordAuthentication=yes'
    );
    
    #Alias for dev.test1.com
    
    $aliases['aliasname1'] = array(
      'root' => '/var/www/html/drupal1',  //path to remote drupal site
      'uri' => 'dev.test1.com',          // URL 
      'remote-user' => 'username',      // ssh username
      'remote-host'=> 'XX.YYY.XX.XXX,   // Your private IP 
      'ssh-options' => '-o PasswordAuthentication=yes'
    );
    
    #Alias for dev.test2.com
    
    $aliases['aliasname2'] = array(
      'root' => '/var/www/html/drupal2',  //path to remote drupal site
      'uri' => 'dev.test3.com',          // URL 
      'remote-user' => 'username',      // ssh username
      'remote-host'=> 'XX.XXX.XX.XXX,   // Your private IP 
      'ssh-options' => '-o PasswordAuthentication=yes'
    );
    
    

    Reasons to Hire PHP Developers from India for Web Development

    php development services India

    Most businesses desire to stay ahead of their opponent. They also desire to attain success. They desire to leverage the internet and develop their base. That’s why it becomes significant to take the industry online. Going online needs little efforts and an industry will need a feature-rich, strictly superior and attractive web-based product, preferably a website, to attain the target.

    Using PHP brings a range of benefits to industry or brands as this language is packed with features that make it a top preference for web development projects of unreliable scale and magnitude. Over 80% of websites on the internet utilize it which speaks volume about its status and continually growing usages.

    The second significant aspect of this language is its ease as web developers find it simple to learn and understand. Neither does it require developer’s lots of study nor any manual study as it’s easy due to its logical syntax and stress-free command functions. What’s more, it’s compatible with additional scripting languages as well.

    Benefits of Hiring PHP Dedicated Developers:

    For PHP development, one needs extremely professional & knowledgeable PHP Dedicated Developers, as it needs successful implementation & skills. Hire PHP developer expert as it cut the IT costs, with which there is the superior scope of industry development

    The high-performance data store applications in PHP & MySQL get better the organizational productivity with the newest updates in the industry trends.

    The operational costs are reducing with the creation of the automated application development systems which would get better the manual procedure of its users.

    There is broader technical platform support of PHP Development.

    With these advantages, it becomes more attractive to hire php development services India. Hiring the PHP Dedicated Programmers with the aid of outsourcing is more helpful than hiring any local PHP Designers as the charge involved in the outsourcing process is much lower & lucrative method of hiring the professional technicians.

    Why choose PHP developer from India?

    India has turned out to be a new haven for technical expertise, so it’s a very good time to hire a dedicated PHP developer from India who will present the skills required to establish a solid platform on which to develop your website.

    PHP is extensively used in the creation of efficient, dynamic web pages, so when you appoint PHP Developers, you can be sure that you are choosing from a pool of talent that is filled with innovative experts who will include value to your website.

    When you decide to appoint a dedicated PHP developer from India, you will reap the benefits of working with an expert who mixes basic skills with difficult creativity and resourceful devotion.

    In overall, businesses must trust only dedicated PHP developers to make their web projects flourishing. More so, this language has a huge community on the internet to help users with their troubles.

    In a method, your business must benefit from PHP to boost its general productivity and performance. After all, in today’s time, it’s significant to boost the capabilities of the website and this is only potential when it’s enriched with top words.