sftp = ssh.open_sftp() with sftp.file('/tmp/deploy_loja.py', 'w') as f: f.write(remote_script) sftp.close() stdin, stdout, stderr = ssh.exec_command('python3 /tmp/deploy_loja.py') print(stdout.read().decode('utf-8')) print('STDERR:', stderr.read().decode('utf-8')) # Reiniciar servidor Node stdin, stdout, stderr = ssh.exec_command('pm2 restart fatos-investigativos') print('PM2 RESTART:', stdout.read().decode('utf-8')) ssh.close()