title: paramiko-expect change password
body: <p>I have several routers running OpenWRT and I'd like to configure them with a python script using paramiko. Since the 'passwd' command on Linux requires a user input I'm using paramiko-expect to handle the interaction. Changing the password on the host itself looks like the following:</p>
  <pre><code>root@host1:~# passwd
  Changing password for root
  New password: new_password 
  Retype password: new_password
  passwd: password for root changed by root
  </code></pre>
  <p>My python script looks like this</p>
  <pre><code>import paramiko
  from paramiko_expect import SSHClientInteraction
  
  try:
      with paramiko.SSHClient() as ssh:
          ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
          ssh.connect('192.168.1.1', 22, 'root', 'old_password')
          
          with SSHClientInteraction(ssh, timeout=10, display=True) as interact:
              interact.expect('.*root.*') # expecting root@host1:~
              interact.send('passwd')
              interact.expect(['.*password.*', '.*password.*']) # expect multiline output both containing the phrase 'password'
              interact.send('new_password')
              interact.expect('.*password.*') # expect 'Retype password: '
              interact.send('new_password')
  
  except Exception as e:
      print(e)
  </code></pre>
  <p>The script runs with no errors but I can still login with 'old_password', so the password is not changed. Output on my local terminal looks like:</p>
  <pre><code>BusyBox v1.30.1 () built-in shell (ash)
  
  Welcome to OpenWRT
  
  root@host1:~# passwd
  Changing password for root
  New password:
  Retype password:
  </code></pre>
  <p>
  I've tried a simple </p>
  <pre><code>interact.send('ls&gt;test')
  </code></pre>
  <p>The interesting thing is, the file test is created but it has no content (contains several files when executed on host1 itself). The same happens with</p>
  <pre><code>interact.send('ip a&gt;test')
  </code></pre>
  <p>Interestingly a pwd&gt;test works fine and the current directory is added to the test file. Anybody has an idea what the problem is or how I can debug properly?</p>
  <p>
  paramiko 2.7.2<br>
  paramiko-expect 0.3.0<br>
  Python 3.8.5<br>
  terminal I use to execute the python script: platformio-ide-terminal addon for atom 2.10.1
  </p>
  <p>Regards Ian</p>