def sftp_from_config(config):
 host = config[u'host']
 port = config[u'port']
 username = config[u'username']
 password = config[u'password']
 private_key = config[u'private_key']
 private_key_pass = config[u'private_key_pass']
 conn_conf = ConnectionConfig(host, port, username, password, private_key, private_key_pass)
 try:
  sftp = sftp_connect(conn_conf)
 except Exception as e:
  raise plugin.PluginError((u'Failed to connect to %s (%s)' % (host, e)))
 return sftp

def sftp_from_config ( config ) : host = config [ u'host' ] port = config [ u'port' ] username = config [ u'username' ] password = config [ u'password' ] private_key = config [ u'private_key' ] private_key_pass = config [ u'private_key_pass' ] conn_conf = ConnectionConfig ( host , port , username , password , private_key , private_key_pass ) try : sftp = sftp_connect ( conn_conf ) except Exception as e : raise plugin . PluginError ( ( u'Failed to connect to %s (%s)' % ( host , e ) ) ) return sftp
creates an sftp connection from a flexget config object .