Bug 1942 - mounting home directory with sshfs -o reconnect requires patch for ssh
Summary: mounting home directory with sshfs -o reconnect requires patch for ssh
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 5.8p1
Hardware: All Linux
: P2 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_6_0
  Show dependency treegraph
 
Reported: 2011-10-11 21:40 AEDT by e.kuemmerle
Modified: 2016-08-02 10:42 AEST (History)
1 user (show)

See Also:


Attachments
Patch to add the option "-H path_to_per-user_configdir" to ssh (6.21 KB, patch)
2011-10-11 21:40 AEDT, e.kuemmerle
no flags Details | Diff
ssh-mkdir.diff (1.03 KB, patch)
2011-10-14 21:35 AEDT, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description e.kuemmerle 2011-10-11 21:40:49 AEDT
Created attachment 2097 [details]
Patch to add the option "-H path_to_per-user_configdir" to ssh

Hi,

we are using sshfs to mount the home directories via pam_mount, the server is listed in /etc/ssh/ssh_known_hosts.
The problem is, that ssh always wants to read the directory ~/.ssh.

When the initial connection is established, the ssh process creates the .ssh directory in the empty mount point directory. That doesn't harm because sshfs can be forced with the nonempty option to mount on that directory even though it is no longer empty.

But if the ssh connection to the server breaks and sshfs starts a new ssh process to reconnect, ssh hangs in an uninterruptible sleep (process state = D) when it tries to read ~/.ssh because the mounted home directory is not available...

To overcome this deadlock, I patched ssh:
I added an new option "-H path_to_per-user_configdir" that allows to use path_to_per-user_configdir/.ssh instead of ~/.ssh.
We use now "-H /dev/null". ssh then warns "Could not create directory '/dev/null/.ssh'.", but the sshfs mount works properly, including the reconnect feature.

IMHO that patch could also help other people, so I suggest to integrate it in the openssh sources.

Thank you,
  Eberhard
Comment 1 Damien Miller 2011-10-14 21:35:27 AEDT
Created attachment 2099 [details]
ssh-mkdir.diff

don't mkdir when -F specified
Comment 2 Damien Miller 2011-10-14 21:49:01 AEDT
Think this patch is better, it suppresses the mkdir when the -F option is passed to ssh so you can use "ssh -F /dev/null"
Comment 3 e.kuemmerle 2011-10-15 00:33:29 AEDT
Suppressing mkdir ~/.ssh is not enough because ssh still tries to open some files in that directory!
An alternative patch additionally has to suppress all these open calls!
Then it would work, indeed.

But I think it is more useful to provide the possibility to use a different directory.
Comment 4 Damien Miller 2011-10-15 10:25:26 AEDT
You can suppress other attempts to read/write from ~/.ssh using already-existing configuration options (UserKnownHostsFile etc)
Comment 5 e.kuemmerle 2011-10-17 20:10:27 AEDT
Ok, with the options

-oUserKnownHostsFile=/dev/null -oUserKnownHostsFile2=/dev/null -oIdentityFile=/dev/null -F /dev/null

your patch would solve the remaining problem.
Comment 6 Damien Miller 2011-12-02 11:12:46 AEDT
The patch has been committed, it will be in OpenSSH-6.0
Comment 7 Damien Miller 2016-08-02 10:42:20 AEST
Close all resolved bugs after 7.3p1 release