Everytime I boot, I use
sshfs to mount remote directories. I am thinking to put these short commands in my .bashrc, but that does not seem to be The Right Way™.
What is the proper way to run
sshfs on login?
You can perform sshfs mounts at boot time, but that only works if you don't need any interactive authentication: in most setups this means a passwordless key. (There are other ways, but they only apply inside trusted networks where you would typically already have something like NFS.)
If you need to type a password to send to the remote server, you need to log in and have a user interface available first. Same thing if you need to type a password to unlock a key.
Most window managers and desktop environments allow you to run custom commands when you log in. You can run a snippet like the following (assuming your environment already starts an SSH agent — most do these days):
If you don't have the
For a text mode log in, put
If you want to mount file systems at boot, you need to put them into your
That format will work well. Your IP then the directory you want to mount. And then where you want to mount it on the remote server.
This might be an easier way to do it, but I can't speak on the security of this method:
Create a file at
Make sure to add in your proper user name, ip, group id, and user id.
Final note: execute the above command once before expecting it to auto-mount on reboot.