SSHHook(ssh_conn_id=None, remote_host=None, username=None, password=None, key_file=None, port=None, timeout=10, keepalive_interval=30)¶
Hook for ssh remote execution using Paramiko. ref: https://github.com/paramiko/paramiko This hook also lets you create ssh tunnel and serve as basis for SFTP file transfer
ssh_conn_id (str) – connection id from airflow Connections from where all the required parameters can be fetched like username, password or key_file. Thought the priority is given to the param passed during init
remote_host (str) – remote host to connect
username (str) – username to connect to the remote_host
password (str) – password of the username to connect to the remote_host
key_file (str) – path to key file to use to connect to the remote_host
port (int) – port of remote host to connect (Default is paramiko SSH_PORT)
timeout (int) – timeout for the attempt to connect to the remote_host.
keepalive_interval (int) – send a keepalive packet to remote host every keepalive_interval seconds
Opens a ssh connection to the remote host.
- Return type
__exit__(self, exc_type, exc_val, exc_tb)¶
get_tunnel(self, remote_port, remote_host='localhost', local_port=None)¶
Creates a tunnel between two hosts. Like ssh -L <LOCAL_PORT>:host:<REMOTE_PORT>.
create_tunnel(self, local_port, remote_port=None, remote_host='localhost')¶