LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (https://www.linuxquestions.org/questions/general-10/)
-   -   mounting ssh over the network prompt for password everytime (https://www.linuxquestions.org/questions/general-10/mounting-ssh-over-the-network-prompt-for-password-everytime-4175499621/)

mia_tech 03-27-2014 01:06 AM

mounting ssh over the network prompt for password everytime
 
I set up a mount point over an ssh using sshfs. I added this to fstab file
Code:

sshfs#user@192.168.10.10:/home/user /media/ssh fuse user 0 0
but when I run
Code:

sudo mount -a
the remote host prompts me for password. So I exported my ssh key to remote host using
Code:

ssh-keygen
and put it in .ssh/ directory on remote host, but still prompts me for password

evo2 03-27-2014 02:10 AM

Hi,

I suggest you try to get this working just with ssh and then once that works, you can try using sshfs.

So, standard approach:
Code:

ssh -vvvv user@192.169.10.10
If that doesn't provide enough information, the next step is to look in the log from sshd. That would be /var/log/auth.log on Debian derived systems or /var/log/secure on RHEL derived systems.

Finally if you still cant work it out you should run an instance of sshd in debug mode.

There are many threads here on LQ that cover debugging ssh connection problems.

Evo2.

mia_tech 03-27-2014 02:26 AM

Quote:

Originally Posted by evo2 (Post 5142030)
Hi,

I suggest you try to get this working just with ssh and then once that works, you can try using sshfs.

So, standard approach:
Code:

ssh -vvvv user@192.169.10.10
If that doesn't provide enough information, the next step is to look in the log from sshd. That would be /var/log/auth.log on Debian derived systems or /var/log/secure on RHEL derived systems.

Finally if you still cant work it out you should run an instance of sshd in debug mode.

There are many threads here on LQ that cover debugging ssh connection problems.

Evo2.

when I ssh into the host directly, it works
Code:

ssh user@hostname
but when I try to mount
Code:

sudo sshfs user@hostname:/home/user /media/share
it prompts me for authentication on the remote box

evo2 03-27-2014 02:44 AM

Hi,
Quote:

Originally Posted by mia_tech (Post 5142033)
when I ssh into the host directly, it works
Code:

ssh user@hostname

Ok, good.
Quote:

but when I try to mount
Code:

sudo sshfs user@hostname:/home/user /media/share
it prompts me for authentication on the remote box
Why are you using sudo? Using sudo means that sshfs is being run as root, not by you, and as such will not be using your private key.

Evo2.

mia_tech 03-27-2014 03:30 AM

yes, I know, but I thought that sshfs needed sudo priviliges.... anyways, I tried running without sudo and still didn't work, and it was b/c of permission /media/share was created with sudo, so I had to give it the right permission in order to mount with sshfs..... but now it ask me for passphrase to my key... I guess that when I created the key, I entered a passphrase. I'm gonna have to recreate the key without passphrase... but I think I got it working. It was a permission issue

evo2 03-27-2014 03:46 AM

Hi,

you don't need sudo, you just need to change ownership or permissions of the mount point and to be a member of the fuse group.

See /usr/share/doc/sshfs/README.Debian

Evo2.

mia_tech 03-27-2014 12:37 PM

Quote:

Originally Posted by evo2 (Post 5142059)
Hi,

you don't need sudo, you just need to change ownership or permissions of the mount point and to be a member of the fuse group.

See /usr/share/doc/sshfs/README.Debian

Evo2.

well, I'm almost there. I'm able to login without password and able to mount with sshfs, but I wanted to mount at boot time, so I added
Code:

sshfs#user@192.168.10.10:/home/user        /media/user        fuse        user        0        0
to my /etc/fstab file, but that file runs with different priviliges than mine, so it will not mount. Becuase to execute all mount points on that file I run
Code:

sudo mount -a
and I'm back to square one, how do I get around that?

schneidz 04-01-2014 11:16 AM

the system's /etc/fstab acts like root.

for my xbmc machine i put the sshfs command in the users crontab as a @reboot declarative.

evo2 04-01-2014 05:29 PM

Hi,
Quote:

Originally Posted by schneidz (Post 5144770)
the system's /etc/fstab acts like root.

What do you mean by this? Are your referring to root calling "mount -a" and the mounting of devices that are not tagged "noauto"?

Quote:

for my xbmc machine i put the sshfs command in the users crontab as a @reboot declarative.
That is a separate issue to having entries in /etc/fstab/.

Evo2.

evo2 04-01-2014 05:32 PM

Hi,
Quote:

Originally Posted by mia_tech (Post 5142338)
to my /etc/fstab file, but that file runs with different priviliges than mine, so it will not mount.

That file does not "run" at all. It is a configuration file read by the mount command.
Quote:

Becuase to execute all mount points on that file I run
Code:

sudo mount -a
and I'm back to square one, how do I get around that?
Why are you running that? You should be doing
Code:

mount /media/user
Evo2.

evo2 04-01-2014 05:41 PM

Hi,

one more thing. To prevent root from mounting /media/user, you should add the noauto option. Eg
Code:

sshfs#user@192.168.10.10:/home/user        /media/user        fuse        user,noauto        0        0
If you do want root to mount this for you then (eg via the "mount -a" call at boot time) you can have the remote hosts user accept roots public key (ie add it to the ~/.ssh/authroized_keys file), and specify the uid and gid as mount options. Eg
Code:

sshfs#user@192.168.10.10:/home/user        /media/user        fuse        uid=XXXX,gid=YYYY        0        0
Where XXXX and YYYY are for the local user.

HTH,

Evo2.

schneidz 04-02-2014 10:50 AM

http://www.linuxquestions.org/questi...6/#post5084489

heres mine:
Code:

schneidz@xbmc:~$ cat .profile | tail
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

#/home/schneidz/bin/masq.ksh &
(sleep 45 && /usr/bin/sshfs schneidz@mom:media/stuff hyper) &> /dev/null &

hth.


All times are GMT -5. The time now is 04:16 AM.