Getting "TypeError: 'NoneType' object is not iterable" while doing parallel ssh
<p>I am trying to do parallel ssh on servers. While doing this, i am getting "TypeError: 'NoneType' object is not iterable" this error. Kindly help.</p>

<p>My script is below</p>

<pre><code>from pssh import ParallelSSHClient
from pssh.exceptions import AuthenticationException, UnknownHostException, ConnectionErrorException

def parallelsshjob():
        client = ParallelSSHClient(['10.84.226.72','10.84.226.74'], user = 'root', password = 'XXX')
        try:
                output = client.run_command('racadm getsvctag', sudo=True)
                print output
        except (AuthenticationException, UnknownHostException, ConnectionErrorException):
                pass
        #print output

if __name__ == '__main__':
        parallelsshjob()
</code></pre>

<p>And the Traceback is below</p>

<pre><code>Traceback (most recent call last):
  File "parallelssh.py", line 17, in &lt;module&gt;
    parallelsshjob()
  File "parallelssh.py", line 10, in parallelsshjob
    output = client.run_command('racadm getsvctag', sudo=True)
  File "/Library/Python/2.7/site-packages/pssh/pssh_client.py", line 520, in run_command
    raise ex
TypeError: 'NoneType' object is not iterable
</code></pre>

<p>Help me with the solution and also suggest me to use ssh-agent in this same script. Thanks in advance.</p>

<p>From reading the code and debugging a bit on my laptop, I believe the issue is that you don't have a file called <code>~/.ssh/config</code>. It seems that <code>parallel-ssh</code> has a dependency on OpenSSH configuration, and this is the error you get when that file is missing.</p>

<p><code>read_openssh_config</code> returns None here: <a href="https://github.com/pkittenis/parallel-ssh/blob/master/pssh/utils.py#L79" rel="nofollow">https://github.com/pkittenis/parallel-ssh/blob/master/pssh/utils.py#L79</a></p>

<p>In turn, <code>SSHClient.__init__</code> blows up when trying to unpack the values it expects to receive: <a href="https://github.com/pkittenis/parallel-ssh/blob/master/pssh/ssh_client.py#L97" rel="nofollow">https://github.com/pkittenis/parallel-ssh/blob/master/pssh/ssh_client.py#L97</a>.</p>

<p>The fix is presumably to get some sort of OpenSSH config file in place, but I'm sorry to say I know nothing about that.</p>

<p><strong>EDIT</strong></p>

<p>After cleaning up some of <code>parallel-ssh</code>'s exception handling, here's a better stack trace for the error:</p>

<pre><code>Traceback (most recent call last):
  File "test.py", line 11, in &lt;module&gt;
    parallelsshjob()
  File "test.py", line 7, in parallelsshjob
    output = client.run_command('racadm getsvctag', sudo=True)
  File "/Users/smarx/test/pssh/venv/lib/python2.7/site-packages/pssh/pssh_client.py", line 517, in run_command
    self.get_output(cmd, output)
  File "/Users/smarx/test/pssh/venv/lib/python2.7/site-packages/pssh/pssh_client.py", line 601, in get_output
    (channel, host, stdout, stderr, stdin) = cmd.get()
  File "/Users/smarx/test/pssh/venv/lib/python2.7/site-packages/gevent/greenlet.py", line 480, in get
    self._raise_exception()
  File "/Users/smarx/test/pssh/venv/lib/python2.7/site-packages/gevent/greenlet.py", line 171, in _raise_exception
    reraise(*self.exc_info)
  File "/Users/smarx/test/pssh/venv/lib/python2.7/site-packages/gevent/greenlet.py", line 534, in run
    result = self._run(*self.args, **self.kwargs)
  File "/Users/smarx/test/pssh/venv/lib/python2.7/site-packages/pssh/pssh_client.py", line 559, in _exec_command
    channel_timeout=self.channel_timeout)
  File "/Users/smarx/test/pssh/venv/lib/python2.7/site-packages/pssh/ssh_client.py", line 98, in __init__
    host, config_file=_openssh_config_file)
TypeError: 'NoneType' object is not iterable
</code></pre>

python ssh ssh-agent