How to mount automatically sshfs when RSA authentication is not an option?

9,629

Solution 1

This worked for me:

echo $mypassword | sshfs -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no user@host mountpoint -o workaround=rename -o password_stdin 

Solution 2

You can use the sshpass command to login via password authentication, but non-interactively:

echo "MyPassword" > passwordfile
chmod 600 passwordfile
sshpass -f passwordfile [ssh parameters]

Using this technique is not recommended, as it causes a number of security issues. From sshpass man page:

It is close to impossible to securely store the password, and users of sshpass should consider whether ssh's public key authentication provides the same end-user experience, while involving less hassle and being more secure.

You can then use the ssh_command option of sshfs to use sshpass instead of plain ssh

sshfs user@host mountpoint -o ssh_command='sshpass -f passwordfile ssh'
Share:
9,629

Related videos on Youtube

ps-aux
Author by

ps-aux

Updated on September 18, 2022

Comments

  • ps-aux
    ps-aux almost 2 years

    I would like to mount a file system on a remote machine automatically at each Linux startup. However I always need to use password authentication because I cannot use ssh-copy-id. How do I make this to be automatic without manual interaction?

    • derobert
      derobert over 9 years
      Does "can't use ssh-copy-id" mean you can't change anything on the server? Or just you can't use a ~/.ssh/authorized_keys file? (There are more than two authentication options.)
  • Ilia
    Ilia over 4 years
    Using the last example with ssh_command option is the only command that works when connecting to FreeBSD.