using pexpect pxssh twice on two different ports
<p>I am trying to connect via SSH using pxssh to a remote device, however one of these devices is SSH port 2222 and one is 22. I know I can change the hardcoded value in pxssh.py to either 22 or 2222 but I don't know how I can do both at the same time. </p>

<p>I looked at the pxssh login() function and tried putting 'port' after password, so when calling pxssh I could specify the port required e.g</p>

<p>pxssh.py file</p>

<pre><code>def login (self, server, username, password='', port, terminal_type='ansi',original
            _prompt=r"[#$]", login_timeout=10,
            auto_prompt_reset=True, ssh_key=None, quiet=True,
            sync_multiplier=1, check_local_ip=True):
</code></pre>

<p>calling pxssh login from my file</p>

<pre><code>s.login(server, username, password, port) 
</code></pre>

<p>however that error'ed with</p>

<pre><code>SyntaxError: non-default argument follows default argument
</code></pre>

<p>I then thought I could duplicate pxssh and have pxssh22.py and pxssh2222.py</p>

<pre><code>if something:
     from pexpect import pxssh22
else:
     from pexpect import pxssh2222
</code></pre>

<p>each specifying a different hard coded port number however that kept erroring with when called:</p>

<pre><code>try:
    s = pxssh2222.pxssh()
    s.login(server, username, password)

except pxssh2222.ExceptionPxssh as e:
NameError: global name 'pxssh2222' is not defined
</code></pre>

<p>How could I use pxssh to access both port 2222 and 22. Thanks</p>