config path in ssh-config

This commit is contained in:
q
2025-04-22 13:12:33 +03:00
parent aa317c1352
commit 904a8eec05

View File

@@ -10,6 +10,9 @@ _helpexit() {
-nosave will not use host key checking, nor save it anywhere. potentially dangerous. -nosave will not use host key checking, nor save it anywhere. potentially dangerous.
-nofollow disable symlinks following -nofollow disable symlinks following
If you add 'host myhost # sshfs' line to ~/.ssh/config the entries will be listed first.
Adding a remote path at the end: 'host myhost # sshfs /my/path' in ~/.ssh/config will use that path as default remotepath
" "$( basename $0 )" " "$( basename $0 )"
_current_mounts _current_mounts
exit 1 exit 1
@@ -56,14 +59,22 @@ for (( i=1; i<=$#; i++ )); do
if [[ -z "$host" ]]; then if [[ -z "$host" ]]; then
host="${!i}" host="${!i}"
else else
localpath="${!i}" remotepath="${!i}"
fi fi
done done
mkdir -p ~/mnt mkdir -p ~/mnt
valid_name=$( echo "$host" | sed -e 's/[^A-Za-z0-9._@-]//g') valid_name=$( echo "$host" | sed -e 's/[^A-Za-z0-9._@-]//g')
path=:"${localpath}" if [[ -z "$remotepath" ]]; then
if [[ -e ~/.ssh/config ]]; then
if grep -q ^"host $host # sshfs" ~/.ssh/config; then
# pick only string after 'sshfs'
remotepath=$( grep ^"host $host # sshfs" ~/.ssh/config | head -n 1 | sed "s/^host $host # sshfs //" )
fi
fi
fi
path=:"${remotepath}"
if [[ "$nosave" = true ]]; then if [[ "$nosave" = true ]]; then
NOSAVE="-o ssh_command='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'" NOSAVE="-o ssh_command='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'"