You are not logged in.

#1 2010-10-09 13:20:05

diederick76
Member
Registered: 2010-02-14
Posts: 169

[solved] Automounting ssh filesystems

Hi,

I would like to mount filesystems over ssh using sshfs and autofs. I have two ssh filesystems, one on host 'bob' and one on host 'bender'. I have a dns system and static ips set up so I can access hosts by their names. On my user's desktop folder (called 'bureaublad') I have two empty folders named 'bob' and 'bender' which I use as mount points, like so:

sshfs diederick@bender:~/ /home/diederick/bureaublad/bender
sshfs diederick@bob:~/ /home/diederick/bureaublad/bob

This works nicely. Now I don't want to open a terminal window and enter this line every time I have to access these hosts, so I'd like to use autofs to mount them whenever I access the mount points. Following the steps at http://wiki.archlinux.org/index.php/Autofs#Remote_SSH I have created an auto.ssh file with these contents:

bender    -fstype=fuse,rw,allow_other,IdentityFile=/home/diederick/.ssh/id_rsa :sshfs #diederick@bender\:~/
bob    -fstype=fuse,rw,allow_other,IdentityFile=/home/diederick/.ssh/id_rsa :sshfs\#diederick@bob\:~/

The contents of my auto.master file are:

# Sample auto.master file
# Format of this file:
# mountpoint map options
# For details of the format look at autofs(5).

#/media /etc/autofs/auto.media
/home/diederick/bureaublad/bender    /etc/autofs/auto.ssh    --timeout=60
/home/diederick/bureaublad/bob        /etc/autofs/auto.ssh    --timeout=60

Now when I start the aufofs daemon and cd into ~/bureaublad/bender/ or ~/bureaublad/bob/, instead of the contents of the remote file system, I see two folders, one named 'bender' and one named 'bob':

diederick@zaphod:~$ ls -la bureaublad/bender/
total 4
drwxr-xr-x 4 root      root         0 Oct  9 15:01 .
drwxr-xr-x 6 diederick diederick 4096 Oct  9 14:52 ..
dr-xr-xr-x 2 root      root         0 Oct  9 15:01 bender
dr-xr-xr-x 2 root      root         0 Oct  9 15:01 bob

When I try to cd into 'bender' or 'bob' this happens:

diederick@zaphod:bender$ cd bender/
bash: cd: bender/: No such file or directory

Can somebody tell me what I'm missing?

Thanks for any help!

Last edited by diederick76 (2010-10-10 21:25:11)

Offline

#2 2010-10-09 13:45:50

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [solved] Automounting ssh filesystems

A few problems i see:

- your first ssh line for bender has a space instead of a backward flash before the #

- you're including auto.ssh twice in auto.master, while you're supposed to enter a single parent directory. e.g.:

/media/ssh              /etc/autofs/auto.ssh    --timeout=60

In this case, any targets in auto.ssh will be automatically created as directories like /media/ssh/bender/ when you start autofs.

- i'm not sure if a tilde ~ works when you mount through autofs, you might want to try using a full path just in case or place a backward slash before it.


ᶘ ᵒᴥᵒᶅ

Offline

#3 2010-10-09 14:51:49

diederick76
Member
Registered: 2010-02-14
Posts: 169

Re: [solved] Automounting ssh filesystems

The space instead of the slash was a typo in my post. Your other suggestion did the trick. Thanks! smile

Offline

#4 2010-10-09 15:22:19

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [solved] Automounting ssh filesystems

diederick76 wrote:

The space instead of the slash was a typo in my post. Your other suggestion did the trick. Thanks! smile

Great, please mark your topic solved. smile


ᶘ ᵒᴥᵒᶅ

Offline

#5 2010-10-09 17:08:47

diederick76
Member
Registered: 2010-02-14
Posts: 169

Re: [solved] Automounting ssh filesystems

Actually, I was to early with my last remark. sad

One of the machines, bender, mounts as expected and without problem, the other, bob, does not.

My auto.ssh is now:

bob    -fstype=fuse,rw,allow_other,IdentityFile=/home/diederick/.ssh/id_rsa :sshfs\#diederick@bob\:/home/diederick/
bender    -fstype=fuse,rw,allow_other,IdentityFile=/home/diederick/.ssh/id_rsa :sshfs\#diederick@bender\:/home/diederick/

And my auto.master:

# Sample auto.master file
# Format of this file:
# mountpoint map options
# For details of the format look at autofs(5).

#/media /etc/autofs/auto.media
/home/diederick/bureaublad        /etc/autofs/auto.ssh    --timeout=60

When I cd into bureaublad/bender/, I see the remote filesystem. But when I cd into bureaublad/bob, I get:

diederick@zaphod:~$ cd bureaublad/bob/
bash: cd: bureaublad/bob/: No such file or directory

daemons.log shows these lines when I do that:

Oct  9 19:03:46 localhost automount[3973]: attempting to mount entry /home/diederick/bureaublad/bob
Oct  9 19:03:46 localhost automount[3973]: >> read: Connection reset by peer
Oct  9 19:03:46 localhost automount[3973]: mount(generic): failed to mount sshfs#diederick@bob:/home/diederick/ (type fuse) on /home/diederick/bureaublad/bob
Oct  9 19:03:46 localhost automount[3973]: failed to mount /home/diederick/bureaublad/bob
Oct  9 19:03:46 localhost automount[3973]: attempting to mount entry /home/diederick/bureaublad/bob
Oct  9 19:03:46 localhost automount[3973]: failed to mount /home/diederick/bureaublad/bob

Is there any way to find out what's going on here? ssh'ing directly into bob works fine, the keys are okay and mounting manually using sshfs works without issue as well. The only difference between the machines is that bob has a wireless connection.

Last edited by diederick76 (2010-10-09 17:10:32)

Offline

#6 2010-10-10 08:23:56

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [solved] Automounting ssh filesystems

You can add the debug flag to auto.master for verbose log-output:

/home/diederick/bureaublad        /etc/autofs/auto.ssh    --timeout=60 --debug

Don't forget to remove it again after testing or it will clog your logs. wink


ᶘ ᵒᴥᵒᶅ

Offline

#7 2010-10-10 09:53:34

diederick76
Member
Registered: 2010-02-14
Posts: 169

Re: [solved] Automounting ssh filesystems

litemotiv wrote:

You can add the debug flag to auto.master for verbose log-output:

/home/diederick/bureaublad        /etc/autofs/auto.ssh    --timeout=60 --debug

Don't forget to remove it again after testing or it will clog your logs. wink

That seemed to work, thanks smile . The --debug told me what command was used to mount bob's filesystem, and on executing that line manually I found that host bob was apparently unknown. After confirming the key fingerprint, autofs mounting works.  Still, I wonder how that can be, since ssh'ing into bob already worked fine. Does autofs store its keys separately?

Offline

#8 2010-10-10 10:10:04

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [solved] Automounting ssh filesystems

diederick76 wrote:

That seemed to work, thanks smile . The --debug told me what command was used to mount bob's filesystem, and on executing that line manually I found that host bob was apparently unknown. After confirming the key fingerprint, autofs mounting works.  Still, I wonder how that can be, since ssh'ing into bob already worked fine. Does autofs store its keys separately?

Autofs mounts as root, while you probably tested as a regular user before. That's why the wiki mentions to test the connection with sudo. wink


ᶘ ᵒᴥᵒᶅ

Offline

#9 2010-10-10 19:50:34

diederick76
Member
Registered: 2010-02-14
Posts: 169

Re: [solved] Automounting ssh filesystems

litemotiv wrote:
diederick76 wrote:

That seemed to work, thanks smile . The --debug told me what command was used to mount bob's filesystem, and on executing that line manually I found that host bob was apparently unknown. After confirming the key fingerprint, autofs mounting works.  Still, I wonder how that can be, since ssh'ing into bob already worked fine. Does autofs store its keys separately?

Autofs mounts as root, while you probably tested as a regular user before. That's why the wiki mentions to test the connection with sudo. wink

Right. Thanks!

BTW I can't find a 'resolved' button/link.

Last edited by diederick76 (2010-10-10 19:52:23)

Offline

#10 2010-10-10 20:13:29

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,680

Re: [solved] Automounting ssh filesystems

diederick76 wrote:

BTW I can't find a 'resolved' button/link.

Just edit the opening post and prepend [solved] to the title

Offline

Board footer

Powered by FluxBB