Выполнение команд/скриптов на удаленных серверах https://rtfm.co.ua/python-modul-fabric/ http://www.fabfile.org или использовать paramico import paramiko res_list = list() i = 0 # counter while True: plpy.notice('Trying to connect to %s (%i from %i times)" % (host_ip, i, retry_time)') try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(hostname=host_ip, port=port, username=username, password=userpass) break except paramiko.AuthenticationException as e: plpy.error('Authentication failed when connecting to %s (%s)' % (host_ip, e.message)) return None except Exception as e: plpy.error("Could not SSH to %s, waiting for it to start (%s)" % (host_ip, str(e))) i += 1 time.sleep(2) # If we could not connect within time limit if i >= retry_time: plpy.error('Could not connect to %s. Giving up' %...