DWQA QuestionsCategory: ProgramFailure to connect to port 22 on exception?
Dream chaser asked 1 year ago

A simple code is written according to the official document of fabric:

from fabric.api import run

def host_type():
    run('uname -s')

Runtime:[email protected]:~/test_folder$ fab -H yangxg.top host_type
The domain name of the host is: yangxg.top
The following abnormal information is obtained:

[email protected]:~/test_folder$ fab -H yangxg.top host_type
[yangxg.top] Executing task 'host_type'
[yangxg.top] run: uname -s

Fatal error: Low level socket error connecting to host yangxg.top on port 22: Unable to connect to port 22 on  or 23.83.225.228 (tried 1 time)

Underlying exception:
    Unable to connect to port 22 on  or 23.83.225.228

Aborting.

Why does this happen? It can ensure that the SSH service of the remote host has been turned on and can be connected by using putty and other tools. Fabric version is 1.10.2, python version is 2.7
For advice!

1 Answers
citaret answered 1 year ago

Have you changed itsshPort number of?

Dream chaser replied 1 year ago

Thank you! Check it is really changed, change the connection port number.