3
i want to set up SSHFS such that whenever I SSH into remote server, it mounts the file transfer folder. Is it possible to set it up in such way?
making script after @Alex's comment.
my script is very simple.
#! /bin/bash
#login in the server
ssh -X user@0.0.0.0
#establish the automated mounting
sshfs user@0.0.0.0:/home/usr/data /usr/some/place/mountedfolder/ -ovolname=mounted-folder
but now, if i execute this file. first the ssh is established and then only after i exit ssh the folder is mounted with sshfs
.
What am i doing wrong here?
okay for now, i just did simple fix :-> switched the order of commands. first the sshfs
and then ssh
so that : first it mounts and second it establishes ssh
connection.
#! /bin/bash
#establish the automated mounting
sshfs user@0.0.0.0:/home/usr/data /usr/some/place/mountedfolder/ -ovolname=mounted-folder
#login in the server
ssh -X user@0.0.0.0
seems like it works for now.
Just run
SSHFS
thenssh
in the same shell script. – Alex – 2017-02-15T12:02:07.527this could be.. i am right now just using the single line on the terminal to ssh. may be yes make a script to do both. thanks for the idea. i feel dumb now. – hadi k – 2017-02-15T12:53:37.673
@Alex : i nearly went full retard, just re-read your comment again and you do point out the order of execution for the commands -.- – hadi k – 2017-02-15T13:39:01.667
2No, you good. As old wisdom says: "The only those who doing nothing never makes mistakes" – Alex – 2017-02-15T17:37:56.730
I think you have to move the corrected(working) part of the script to the answer and accept your own answer, it absolutely Ok with policy of this site and those who would look for the similar solution may find it useful – Alex – 2017-02-16T04:40:18.510
1No problem, I would advise you to add one more line of code - run SSHFS unmount command after
ssh
. This way if you logout from remote machine, it will automatically unmount SSHFS too, releasing mount point for something else – Alex – 2017-02-16T12:15:21.713