Note that there are some explanatory texts on larger screens.

plurals
  1. POsshfs not using password in expect script
    primarykey
    data
    text
    <p>I've written a little script to supply a password to sshfs, but for some reason sshfs isn't grabbing the password. Any pointers? (PS I know ssh keys are better/safer, but politics where I work prevents key based authentication being setup on the target server - sigh... ).</p> <pre><code>#!/usr/bin/expect # NOT WORKING!! exp_internal 1 spawn sshfs server:/export/pc_storage /home/sonia/mnt/server expect { "assword:" { send "secret\r\r" send_user "\n" } timeout { send_user "timed out!\n" } } </code></pre> <p>To terminate the password, I've tried \r \n \r\r - none work.</p> <p>Debugging output, showing that password prompt is triggering:</p> <pre><code>spawn sshfs server:/export/pc_storage /home/sonia/mnt/server parent: waiting for sync byte parent: telling child to go ahead parent: now unsynchronized from child spawn: returns {17532} expect: does "" (spawn_id exp6) match glob pattern "assword:"? no pcuser@server's password: expect: does "pcuser@server's password: " (spawn_id exp6) match glob pattern "assword:"? yes expect: set expect_out(0,string) "assword:" expect: set expect_out(spawn_id) "exp6" expect: set expect_out(buffer) "pcuser@server's password:" send: sending "secret\r\r" to { exp6 } % uname -a Linux zapote 2.6.38-10-generic-pae #46-Ubuntu SMP Tue Jun 28 16:54:49 UTC 2011 i686 i686 i386 GNU/Linux % sshfs -V SSHFS version 2.2 FUSE library version: 2.8.4 fusermount version: 2.8.4 using FUSE kernel interface version 7.12 </code></pre> <p>SOLVED:</p> <p>(I can't post an answer as I don't have 100 points - double sigh)</p> <p>I need to fix this up a bit... For example I hard coded PS1 in my .bashrc to "bash_prompt" (I use zsh by default).</p> <pre><code>#!/usr/bin/expect # FIX: get homedir from env, set bash prompt somehow... set timeout 30 spawn /bin/bash expect "bash_prompt" send_user "Shell spawned.\n" send -- "sudo umount /home/sonia/mnt/server &amp;&gt; /dev/null\r" expect "bash_prompt" send -- "sshfs server:/export/pc_storage /home/sonia/mnt/server\r" expect { "assword:" { send "secret\r" send_user "\n" } timeout { send_user "timed out!\n" } } expect "bash_prompt" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload