LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-01-2010, 10:01 PM   #1
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Rep: Reputation: 54
issues with mount.cifs


I want to use sshfs but can't seem to find any info on using public keys, guessing it's not supported. I need a mount method that is automated, so I setup a smb user on the remote server and I use mouunt.cifs and supply the username and password. It mounts ok.

Now I have a windows box which accesses the server (via smb) that has the mount on it, but for whatever reason, I get all sorts of access denied errors when I try to write to that share! I need read and write. How do I go about making this happen?

So just as a recap:

server1 has files that are shared
server2 mounts to server1
client1 mounts to server2, and needs to write to the mount that goes to server1.
 
Old 12-02-2010, 03:51 PM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Quote:
Originally Posted by Red Squirrel View Post
I want to use sshfs but can't seem to find any info on using public keys, guessing it's not supported. I need a mount method that is automated ...
It runs using ssh so it should be transparent.

This guy seems to think so.
 
Old 12-02-2010, 03:54 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
no info? Googling "sshfs public keys" gives me loads of hits, e.g. http://ubuntuforums.org/showthread.php?t=829066
 
Old 12-02-2010, 04:48 PM   #4
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Original Poster
Rep: Reputation: 54
I found that post, but there is no real solution. I still need to know the syntax how to specify the key file when I connect to the server that I put the other key file on in ~/.ssh/authorized_hosts. There is no mention about the other key and how I'm suppose to specify it when calling sshfs. That's the part I'm trying to get to work.
 
Old 12-02-2010, 05:00 PM   #5
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
You don't specify the key. If you use ssh-agent, you get prompted once for the passphrase for the key on local login. Anytime you use ssh (or sshfs) the key is then supplied. Just make sure the server is set up to request a key.
 
Old 12-02-2010, 05:05 PM   #6
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Original Poster
Rep: Reputation: 54
I don't want to get prompted though. This needs to mount at startup. I want to do the same as my rsync backups, set and forget.

I'm actually debating on just using an rsync job in a loop, but that just seems dirty. Basically I am working on a program off an existing samba share on my main server, but I don't want to run that code on my main server, so from the main server, I just map the data to the test server.

I'm also thinking of going back to what I originally had and worked, have the data reside on the main server, and just have a samba share in my fstab on the test server. I was getting TX Unit Hang errors on that dev server so I thought maybe that was the cause which prompted me to rethink my whole setup, but don't think it was since I'm still getting those errors with the code being local. So more I think about it, think I'll just revert back to what I had.
 
Old 12-02-2010, 05:07 PM   #7
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Well create a public/private keypair with an empty passphrase.
 
Old 12-02-2010, 05:13 PM   #8
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Original Poster
Rep: Reputation: 54
I know that part, but I need to tell sshfs what key I'm using when connecting to the server.

Ex in rsync:

Code:
rsync -rbuv --delete-after --delete-excluded --rsh="ssh -p 22 -i cpdev.key" ${sourcepath} ${pathnamedaily}
For another server I might have another key, and so on, so I need to be able to specify it like I am here. I'm trying to figure out the syntax on how to do this with sshfs.
 
Old 12-03-2010, 02:00 AM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you'd offer all keys available by default, you don't need to specify one specifically, unless you're maanging your keys very badly, which is not ssh's fault.
 
Old 12-03-2010, 05:07 PM   #10
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
The OP seems to be under the misunderstanding that sshfs is responsible for the initial ssh connection - it isn't.
I suggest getting a new passphrase-less key pair going under a normal ssh connection in a terminal, then script that connection. Use a different user if necessary, you can always make directories public and share-able.

I would also suggest man ssh - there are several clues to the approach and method described there.

Last edited by smoker; 12-03-2010 at 05:09 PM.
 
Old 12-05-2010, 06:57 AM   #11
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Quote:
Originally Posted by Red Squirrel View Post
I know that part, but I need to tell sshfs what key I'm using when connecting to the server.

Ex in rsync:

Code:
rsync -rbuv --delete-after --delete-excluded --rsh="ssh -p 22 -i cpdev.key" ${sourcepath} ${pathnamedaily}
For another server I might have another key, and so on, so I need to be able to specify it like I am here. I'm trying to figure out the syntax on how to do this with sshfs.
You can also put the necessary options in your ~/.ssh/config where you can defines aliases with certain settings of ssh's options which are necessary for a particular host. E.g.:

host fubar
hostname abc.def.invalid
port 33
user your_foreign_name

host *
forwardagent yes

These will be honored automatically when you specify `ssh fubar` or in any `scp` command.

Nevertheless, as I dislike passphraseless ssh-keys, what about hostbased authentication?
 
Old 12-05-2010, 11:32 AM   #12
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Original Poster
Rep: Reputation: 54
That's far from what I'm trying to do. I just want to know the flag on sshfs on how to specify the key to connect with. The other key would already be on the server I'm connecting to. One being the private, the other the public (I always forget which is which, but you get the idea)

Basically in my rsync command, I specify that I'm connecting with the key called cpdev.key which is stored in the same folder as the rsync script. How do I do that with sshfs? I can't seem to find anything online saying what the flag is.
 
Old 12-05-2010, 11:55 AM   #13
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Quote:
Originally Posted by Red Squirrel View Post
Basically in my rsync command, I specify that I'm connecting with the key called cpdev.key which is stored in the same folder as the rsync script. How do I do that with sshfs? I can't seem to find anything online saying what the flag is.
You can try to use a defined alias as I mentioned, where you can specify (man ssh_config):

host fubar-sshfs
hostname abc.def.invalid
IdentityFile cpdev.key

or use:

sshfs -o IdentityFile=cpdev.key ...
 
Old 12-05-2010, 01:55 PM   #14
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Original Poster
Rep: Reputation: 54
sshfs -o IdentityFile=cpdev.key ..

Thanks that's what I needed. I'll try that.
 
Old 12-25-2010, 12:14 AM   #15
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Original Poster
Rep: Reputation: 54
I finally got around to actually trying this, and it did work, this is my final command, in case anyone ever finds this and needs to do it:

Code:
sshfs -p 34 user@site.com:/home/user/folder /localdisk/folder/ -o allow_other -o IdentityFile=/location/to/keyfile
I have another -o option so I had to specify -o again. Without allow_other, only root can access the mounted files.

Something else I never thought of till now, with sshfs, what happens if the connection to the server is lost? When the connection is then available again, will it reconnect?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cifs "mount error 13 = Permission denied" CIFS SUCKS humbletech99 Linux - Networking 45 04-06-2020 05:31 AM
manual mount cifs works but srcipt mount cifs has mount error (13): Permission denied CADIT Linux - Newbie 6 11-20-2009 02:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration