Sample Header Ad - 728x90

Running sshfs through ssh proxy and passing in passwords: why does this work?

0 votes
0 answers
12 views
I have a remote machine that I must access through a proxy, and so I have set up the remote's ssh alias like so:
Host server
    HostName server-ip
    User my-username
    ProxyCommand ssh my-proxy-machine-alias -W %h:%p
    ServerAliveInterval 30
Both machines are behind a VPN and are set up to require me to use a password when logging in. I **cannot** automate login with ssh keys on these machines. When I set up for work, I mount several directories from the server machine onto my local machine, and running all these commands every time becomes very tedious as I am required to enter my password twice for each mount I wish to create. Therefore I tried to automate this task. At first I tried using a bash script but got stuck. Then I tried using expect, but that failed to work through the proxy for some reason. Recently, I tried again using something like the following:
#!/bin/bash

read -s -p "Enter your password: " user_password
echo

sshfs -o password_stdin server: . <<< $user_password
This is working! But I don't get it -- doesn't this only pass in my password one time? When I run sshfs manually, I have to enter my password twice. So my question is: why does this work?
Asked by Brian (101 rep)
Aug 11, 2025, 03:13 PM