Python paramiko error "TypeError: 'NoneType' object is not iterable" only for a particular computer
Question: While trying to connect to a remote Unix server using `paramiko` I am getting
the error:

> TypeError: 'NoneType' object is not iterable"

Surprisingly, when I try to run the same script, from a different laptop with
same server, username and password, I am able to connect to the server and
execute remote commands.

    
    
     >>> import paramiko
     >>> ssh = paramiko.SSHClient()
     >>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
     >>> ssh.connect(ftpipaddress,username ='akar',password ='change')
     Traceback (most recent call last):
     File "<interactive input>", line 1, in <module>
     TypeError: 'NoneType' object is not iterable
    

Absolutely no clue what might be the issue with the laptop having same Python
2.7 and `paramiko` package installed in it. Please help.


Answer: According to the [documentation](http://paramiko-
docs.readthedocs.org/en/latest/api/client.html), `connect` method does not
return anything. In terms of Python, it means, that this method returns
`None`. You are probably looking for `exec_command` method:

>
>     exec_command(command, bufsize=-1, timeout=None, get_pty=False)
>  
>
> Execute a command on the SSH server. A new Channel is opened and the
> requested command is executed. The command’s input and output streams are
> returned as Python file-like objects representing stdin, stdout, and stderr.
>
> **Parameters:**
>
>   * command (str) – the command to execute
>
>   * bufsize (int) – interpreted the same way as by the built-in file()
> function in Python
>
>   * timeout (int) – set command’s channel timeout. See
> Channel.settimeout.settimeout
>
>

>
> **Returns:** the stdin, stdout, and stderr of the executing command, as a
> 3-tuple
>
> **Raises SSHException:** if the server fails to execute the command

