[Python] Troubleshoot Parmiko to remote server connection

Discussão em 'Python' iniciado por Stack, Julho 4, 2025.

  1. Stack

    Stack Membro Participativo

    Hi, I'm trying to learn about capabilities of Python to work on remote servers. For my setup I have local ServerA and remote ServerB, I need to run py on ServerB to get some output files. There is no any option to do it from anywhere else as it custom setup for security purposes, I only can run it from ServerB. They both are Windows boxes. Server B is on network, I'm able to remote to it with user:pswd and run my script in test mode there.

    But for control and scheduling purposes I would like to operate on local ServerA. And for first step I tried to work with Paramiko to fire ServerB.test.py And I'm getting error like below, I suspect it could be due the fact that I have very uncommon syntax for my account with backslash? Though typing dummy password produces same output, so the problem might be other/bigger.

    import Paramiko
    # Server connection details
    hostname = 'xServerB'
    username = 'rdc\\twil100' # added extra \ for escape, original only single \
    password = 'pswd123'

    try:
    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(hostname, username=username, password=password) # error here

    command = 'print(\'ServerB\')
    stdin, stdout, stderr = client.exec_command(command)
    print (' completed ')
    except Exception as e:
    print(f"An unexpected error occurred: {e}")

    ####################
    An unexpected error occurred: [WinError 10060] A connection attempt failed because the
    connected party did not properly respond after a period of time, or established connection
    failed because connected host has failed to respond

    Continue reading...

Compartilhe esta Página