0

I have trouble to pass a password automatically in my script. This is how it looks like when I do it manually:

sshfs -o nonempty user@sftp.server.com:/ /home/administrator/data

I am now forced to enter the password for sshfs:

password

I try to automate that in a script and pass the password like this to standard input:

#!/bin/bash

echo "password" | sudo -S sshfs -o nonempty user@sftp.server.com:/ /home/administrator/data

When I run the script, I am still forced to enter the password. What am I doing wrong?

Data Mastery
  • 1,555
  • 4
  • 18
  • 60

1 Answers1

0

Looking at the sshfs wiki it seems this is used to mount a remote file system.

This looks like more of a SSH issue really, if your ssh config is configured to use a password only then you'll get prompted. Its better (and more secure) to use a SSH key without a passphrase imo.

As per the wiki:

SSH will ask for the password, if needed. If you do not want to type in the password multiple times a day, see SSH keys.

markc
  • 2,129
  • 16
  • 27
  • that does not help me, it is the way our IT has setup our system. They will not provide me the SSH Keys unfortunately. I know passing the password in a script works, I have seen this before – Data Mastery Oct 07 '20 at 10:03
  • 1
    @DataMastery I found an interesting q/a here you might be able to use one of these but ymmv: https://stackoverflow.com/questions/12202587/automatically-enter-ssh-password-with-script – markc Oct 07 '20 at 17:28