Airflow: How to SSH and run BashOperator from a different server
<p>Is there a way to ssh to different server and run BashOperator using Airbnb's Airflow?
I am trying to run a hive sql command with Airflow but I need to SSH to a different box in order to run the hive shell.
My tasks should look like this:</p>

<ol>
<li>SSH to server1</li>
<li>start Hive shell</li>
<li>run Hive command</li>
</ol>

<p>Thanks!</p>

<p>I think that I just figured it out:</p>

<ol>
<li><p>Create a SSH connection in UI under Admin > Connection. Note: the connection will be deleted if you reset the database</p></li>
<li><p>In the Python file  add the following</p>

<pre><code>from airflow.contrib.operations.ssh_execute_operator import SSHExecuteOperator
sshHook = SSHHook(conn_id=&lt;YOUR CONNECTION ID FROM THE UI&gt;)
</code></pre></li>
<li><p>Add the SSH operator task</p>

<pre><code>t1 = SSHExecuteOperator(
    task_id="task1",
    bash_command=&lt;YOUR COMMAND&gt;,
    ssh_hook=sshHook,
    dag=dag)
</code></pre></li>
</ol>

<p>Thanks!</p>

python ssh airflow