Last active
July 2, 2026 04:26
-
-
Save bskinn/b3e661dc2f3620f01f8999b0fc51827f to your computer and use it in GitHub Desktop.
bash startup-file one-liner for automatic userspace sshfs mount
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ping -w1 -c1 "$remote" > /dev/null && ( mount | grep "$remote" > /dev/null || sshfs "$user@$remote:$remote_path" "$local_mnt_path" -o reconnect,ServerAliveInterval=15 ) | |
| # Ping once and wait a max of 1s. Only advance if the remote responds. | |
| # These could be larger/longer, but it would increase time to first prompt. | |
| # Suppress output. | |
| # | |
| # ping -w1 -c1 "$remote" > /dev/null && ( ... ) | |
| # | |
| # We found the remote; now we check to see if that remote is already mounted | |
| # by grepping the output of mount. We only proceed if grep *fails*, as this | |
| # indicates that the mount doesn't exist yet. Suppress output. | |
| # | |
| # mount | grep "$remote" > /dev/null || ... | |
| # | |
| # Mount doesn't exist, proceed to establish it, with auto-reconnect and active | |
| # server connection polling. | |
| # | |
| # sshfs "$user@$remote:$remote_path" "$local_mnt_path" -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 | |
| # | |
| # Output suppressing could be more aggressive with "> /dev/null 2>&1" | |
| # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment