python - fabric连接远程主机时报:Unable to connect to port 22 on 的异常?
本文介绍了python - fabric连接远程主机时报:Unable to connect to port 22 on 的异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
按照 fabric 的官方文档写的一段简单代码:
from fabric.api import run
def host_type():
run('uname -s')
运行时:zmrenwu@sheepx:~/test_folder$ fab -H yangxg.top host_type
主机的域名是: yangxg.top
得到如下的异常信息:
zmrenwu@sheepx:~/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.
为什么会出现这种情况?可以保证远程主机的 ssh 服务已经开启了的,使用 putty 等工具可以连接。fabric 版本是 1.10.2, python 版本 2.7
求指教!
解决方案
你是不是改了 ssh
的端口号?
这篇关于python - fabric连接远程主机时报:Unable to connect to port 22 on 的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文