Search code examples
bashsshteesshfs

Can I echo my password to two commands?


I'd like to login to a remote machine, and mount my home dir there with a single command. I tried to do it with:

echo myPassword | tee "sshfs [email protected]:/share/home/boriskh /home/boris/Work/molDyn/boriskh@hpchead" | ssh -Y [email protected] 

but it doesn't work. tee says that it doesn't know the -Y option, and if quote both commands - it also works wrong.

Edit:

I found that these thiings put separately also don't work:

echo myPassword | ssh -Y [email protected]
echo myPassword | sshfs [email protected]:/share/home/boriskh /home/boris/Work/molDyn/boriskh@hpchead

Edit2:

To get the required functionality (mounting the remote home and also login there - in a single command with no password prompts) can be easily achieved with keys (with no passphrase - i.e. input Enter as a code):

ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]

That's it. After that the desired functionality is achieved with:

sshfs [email protected]:/share/home/boriskh /home/boris/Work/molDyn/boriskh@hpchead && ssh -Y [email protected]

Solution

  • I think that for that task it should be more comfortable and secure use public keys. It's really easy and there are lot of tutorials.

    Remember not put anything in the passphrase, or it will be like have to type the password.