How to remote mount with password using SSHFS and stdin; Ubuntu sshfs remote mounting; MOSSO

This will allow you to mount a remote ssh filesystem using sshfs (Secure SHell FileSystem):

echo mypassword | sshfs myuser@ftp.mysite.com:/ ~/mnt/mysite -o workaround=rename -o password_stdin

Replace mypassword, myuser, ftp.mysite.com and mysite.

Example:

echo 4ghNZGpk182q8SvY0kw021JbRb34THaPDN8wyXY679BQPSit5A | sshfs jsmith@ftp.example.com:/ ~/mnt/example -o workaround=rename -o password_stdin

NOTE: Make sure the mount folder ~/mnt/example exists or create it:

mkdir -p ~/mnt/example
Did this help you? Please let me know with a comment. Thank you
Posted .

31 comments (RSS)

  1. anonymous

    Many thanks, great solution

  2. anonymous

    BRILLIANT! Thanks.

  3. anonymous

    I'm running this script and keep getting "Timeout waiting for prompt". Any suggestions:

    echo $DESTINATION_PWD | sshfs -o workaround=rename,password_stdin,sshfs_debug $DESTINATION_USER@$DESTINATION_SERVER:$DESTINATION_SERVER_PATH $MOUNT_PATH

  4. anonymous

    regarding the timeout... do it first without the "echo $DESTINATION_PWD | "

    you may need to allow the connection the first time

  5. anonymous

    ... and without password_stdin

  6. anonymous

    Simple and perfect for webserver backup. Thank you!

  7. anonymous

    Thanks. This worked for me. Any security issues with this?

  8. anonymous

    @"security issues" the entry will be in your bash history if you type out the command

  9. anonymous

    Just remember to try the command manually first (or ssh to it) because it will fail waiting for the Y/N question ...

  10. anonymous

    Why won't this work in 'startup applications'? works just fine in the terminal.

  11. anonymous

    look into using fstab to add mount to startup.

  12. anonymous

    thanks, you are genius!

  13. anonymous

    THX!

  14. anonymous

    Excellent... Mind blowing I would say.

  15. anonymous

    Finally after a rigorous search, I got the answer!!! Thank You soooo much...

  16. anonymous

    don't work :(

    "remote host has disconnected"

  17. anonymous

    This is why I'm here ;-)

    "Just remember to try the command manually first (or ssh to it) because it will fail waiting for the Y/N question ..."

    Oops.

  18. anonymous

    BINGO!

  19. anonymous

    thank you, bro!

  20. anonymous

    Very cool. Thanks.

  21. anonymous

    +1

  22. anonymous

    THIS IS AWESOME!

    Not the most secure but gets the job done!

  23. anonymous

    You're genius! Thank you very much! Greetings from Italy, fabriziorubino.it

  24. anonymous

    I get the error "Timeout waiting for prompt". I have previously ssh to the server so it's not the y/n prompt. Trying to do this with Cloud9 to a DigitalOcean server. Any ideas?

  25. anonymous

    How to stick that into fstab or get it working on startup?

  26. anonymous

    Here is some info on mounting partitions in Ubuntu

    https://help.ubuntu.com/community/Fstab

  27. anonymous

    I know how to mount most of the partitions, but fstab will not take echo command...

  28. anonymous

    I put this in a bash script and it works without getting the password prompt. But when the same script run from Jenkins I keep on getting the same message: "Timeout waiting for prompt", so the Jenkins job just failed. Wonder if anybody observed this and could offer a solution or workaround? Thanks much.

  29. anonymous

    Hi,

    after struggling a couple of hours, I found your solution.

    Thanks, man!!!

  30. anonymous

    "Timeout waiting for prompt" happens due to host identity verification while connecting for the very first time. Simply add -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null. The first option allows you to connect to unknown hosts without prompt, the second option prevents the host key from getting stored in the first place, so you won't run into problems if it changes. This is not very secure, but neither is piping the clear-text password...

  31. anonymous

    goood

Leave a comment