Fedora add reomote drive

0

I changed my operating system from Windows to Fedora a few days ago. So I am a really beginner in any Linux stuff.

My basic goal is to add a remote drive (my cloud drive) on start up so I can use it. I tried to create a bash script which will be executed on startup by using sftp. I found the following code

sshfs user@sftp.example.com:/targetpath ~/mountdir

My problem is that this works with root permissions but it does not work with my user permissions. Executing with my normal privileges I get the error read: Connection reset by peer. Because I want to execute this on start up I don't want to use root permissions.

Also I searched for a solution to save my user name and the password but I didn't find something yet so I don't have to type them in every time.


Background

Fstab: I googled a lot which lead me to the fstab file at first. I spent a full day and ended up with breaking the system because the internet connection was not present when starting the system so the target disk could not be included (at least I think that's what was happening).

Script (WebDAV, sftp): I then tried to use WebDAV with

mount -t davfs2 https://webdav.example.com ~/mountdir

but this also only works with root permissions (Error: mount: only "root" can do that). My next step was then to use sftp which kind of seems to work better. But then I got the error mentioned above (Error: read: Connection reset by peer).

I don't want to store the files locally because there is not enough disk space available.

I'm sorry if this is a stupid or very basic question but I don't find any way to go on. Thank you for your help.

miile7

Posted 2019-12-11T11:26:37.320

Reputation: 101

Answers

1

You should never run a script as root! I can come up with some reason to when to run a script as root, but in general, it is not a good idea. sshfs also does not need root to work! :)

This should allow you to mount a remote ssh filesystem with a password using sshfs (It would be better if you could use a certificate instead of a password).

echo <mypassword> | sshfs <myuser>@<site.tld>:/ ~/<myfolder> -o workaround=rename -o password_stdin

Replace <mypassword>, <myuser>, <site.tld> and <myfolder>.

Example:

echo 4ghNZGpk182q8SvY0kw0 | sshfs diblo@ftp.diblo.dk:/ ~/diblo -o workaround=rename -o password_stdin

NOTE: Make sure the mount folder ~/<myfolder> exists or create it (Remember to create the folder from the Linux user you want to run the script):

mkdir -p ~/<myfolder>

Replace <myfolder>.

https://www.darklaunch.com/how-to-remote-mount-with-password-using-sshfs-and-stdin-ubuntu-sshfs-remote-mounting-mosso

Diblo Dk

Posted 2019-12-11T11:26:37.320

Reputation: 584

Thank you for your answer. I will defently check out certificates. But still it does not work. If I execute your script I still get the same error read: Connection reset by peer. If I add sudo in front of your commands it works. Also I had some struggles with my password because it contains an "!". May that be the thing so normal users are not allowed to use "!"? – miile7 – 2019-12-12T08:47:50.960