Weird EOFError with python and paramiko
Question: my code:

    
    
    #!/usr/bin/env python
    # encoding: utf-8
    
    import paramiko
    
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect('10.X.X.X',username='user',password='password')
    
    stdin, stdout, stderr=ssh.exec_command("get system status")
    type(stdin)
    stdout.readlines()
    

Quite simple as I thought, but running throws a traceback:

    
    
    Traceback (most recent call last):
      File "/Users/adieball/Dropbox/Multiverse/Programming/workspace/FortiNet/src/runCommand.py", line 8, in <module>
        ssh.connect('10.X.X.X',username='user',password='password')
      File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/paramiko/client.py", line 325, in connect
        t.start_client()
      File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/paramiko/transport.py", line 492, in start_client
        raise e
      File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/paramiko/transport.py", line 1726, in run
        ptype, m = self.packetizer.read_message()
      File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/paramiko/packet.py", line 386, in read_message
        header = self.read_all(self.__block_size_in, check_rekey=True)
      File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/paramiko/packet.py", line 251, in read_all
        raise EOFError()
    EOFError
    

I'm a bit confused here and maybe I'm blind, but I can't find the problem.

thanks

Obviously: connecting per "normal" ssh and running this command works
perfectly fine :-)

I changed to python 2.7 (the default on Mac) and removed the 3.5 installation
completely. I now get a different error (still EOFError though):

    
    
    Traceback (most recent call last):
      File "/Users/adieball/Dropbox/Multiverse/Programming/workspace/FortiNet/src/runCommand.py", line 8, in <module>
        ssh.connect('10.X.X.X,username='user',password='password')
      File "build/bdist.macosx-10.11-intel/egg/paramiko/client.py", line 325, in connect
      File "build/bdist.macosx-10.11-intel/egg/paramiko/transport.py", line 492, in start_client
    EOFError
    

As said before, I can perfectly fine connect to the box with "normal" ssh. I
also tested python's connectivity with:

    
    
    import socket
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(0.5)
    
    try:
            s.connect(('10.2.2.254',22)) 
    except Exception, e:
            print 'connection failed'
    else:
        print "success"
    
    s.close() 
    

and it worked (i.e. printed "success"), but for whatever reason, paramiko
seems to be unable to connect. I tried my code step by step in a python shell
to see when the error occurs and it happens right after

    
    
    ssh.connect('10.X.X.X',username='user',password='password')
    


Answer: Hi i have faced same error while writing a script to access fortigate remotly.
i can see that you are trying on a forigate too.

I have changed the config on the fortigate under "config system global" and it
worked (i don't know which change actually did it , it needs some trial and
error to know)

    
    
    config system global
         - set admin-server-cert "Fortinet_Factory"
         - set admin-sport 2222
         - set admin-ssh-grace-time 20
         - set admin-ssh-v1 enable
         - set auth-cert "Fortinet_Factory"
         - set dh-params 1024
         - set fgd-alert-subscription advisory latest-threat
         - set gui-theme red
         - set gui-wireless-opensecurity enable
         - set hostname "FortiGate-VM64"
         - set ssh-cbc-cipher disable
         - set ssh-hmac-md5 disable
         - set strong-crypto disable
         - set timezone 04
    end
    

please let me know if you did know which one was essential.

