zoukankan      html  css  js  c++  java
  • python paramiko 各种错误

    Error reading SSH protocol banner

     

    这个错误出现在服务器接受连接但是ssh守护进程没有及时响应的情况(默认是15s).

    要解决这个问题, 需要将paramiko的响应等待时间调长。

    transport.py中def __init__()初始化函数中:
    					
    					

    # how long (seconds) to wait for the SSH banner
    self.banner_timeout = 15

     

    client.py中

    def connect(
    self,
    hostname,
    port=SSH_PORT,
    username=None,
    password=None,
    pkey=None,
    key_filename=None,
    timeout=None,
    allow_agent=True,
    look_for_keys=True,
    compress=False,
    sock=None,
    gss_auth=False,
    gss_kex=False,
    gss_deleg_creds=True,
    gss_host=None,
    banner_timeout=None,
    auth_timeout=None,
    gss_trust_dns=True,
    passphrase=None,
    disabled_algorithms=None,
    ):

    t = self._transport = Transport(
    sock,
    gss_kex=gss_kex,
    gss_deleg_creds=gss_deleg_creds,
    disabled_algorithms=disabled_algorithms,
    )

     

    if banner_timeout is not None:
    t.banner_timeout = banner_timeout

     

    解决方案

    ssh = paramiko.SSHClient() #创建一个ssh对象
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) #选择yes,接受key
    ssh.connect(ip, int(port), username, password, banner_timeout=300,timeout=5) #连接服务器,加上banner_timeout参数

     

    
    				
     

  • 相关阅读:
    bootstrapValidator重新校验/全选回显
    mybatis遍历map参数查询
    location.href传json字符串
    springmvc异步处理
    intellIJ IDEA学习笔记3
    intellIJ IDEA学习笔记2
    intellIJ IDEA学习笔记
    maven国内镜像
    Docker版本Jenkins的使用
    Docker容器网络
  • 原文地址:https://www.cnblogs.com/jeancheng/p/13369493.html
Copyright © 2011-2022 走看看