bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#53847: 28.0.91; Tramp SSHFS: incorrect remote home directory


From: Michael Albinus
Subject: bug#53847: 28.0.91; Tramp SSHFS: incorrect remote home directory
Date: Thu, 10 Mar 2022 12:37:44 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Michael Albinus <michael.albinus@gmx.de> writes:

Hi Philipp,

>> Thanks, but would it maybe be possible to find a better solution? I've
>> been using SSHFS for a while now, and this particular issue is pretty
>> annoying in practice. How about any of the following:
>> - When connecting over SSHFS, ask the remote host (via SSH) for the
>> home directory and cache the result.
>> - Allow the user to configure a per-host static home directory (i.e.
>> just a customizable mapping from hosts + users to home directories). I
>> regularly only connect to 2 hosts with known hostnames and home
>> directories, so at least for me maintaining such a mapping would be
>> feasible.
>> WDYT?
>
> Tramp uses already a cached value for the home directory, under the key
> "~". You could try the following:
>
> (add-to-list 'tramp-connection-properties
>              (list (regexp-quote "/sshfs:user@randomhost.your.domain:")
>                    "~" "/home/user"))
>
> It is untested, and you need a fresh git checkout of master. Please
> report whether it works; I would add the recipe to the manual then.

Well, it didn't work out of the box. So I've pushed a fix to the master
branch in order to support this. Note, that you need the connection
property "~user", with "user" being your remote user name.

The Tramp manual has been enhanced with this new section:

--8<---------------cut here---------------start------------->8---
5.5 Expanding ‘~’ to home directory
===================================

Home directories on remote hosts can be typed as tilde ‘~’.  If
possible, they are expanded to the remote user’s home directory on the
remote host.  Example:

     /ssh:user@host:~
     ⇒ /ssh:user@host:/home/user

   This works in general for ‘ssh’-like methods, and for ‘sudoedit’.
These methods allow also the home directory expansion for another
user, like

     /sudoedit::~otheruser
     ⇒ /sudoedit:root@localhost:/home/otheruser

   For other methods, a home directory can be expanded only if
supported.  This happens for example for the ‘sftp’ method.  Methods,
which require a share directory in the remote file name (‘afp’,
‘smb’), use the value of this share directory as home directory:

     /smb:user@host:~
     ⇒ /smb:user@host:/share

   Since Tramp cannot know in advance which share directory is
intended to use, this expansion can be applied only when a share
directory has been used already.

   The methods ‘adb’, ‘rclone’ and ‘sshfs’ do not support home
directory expansion at all.  However, TRAMP keeps the home directory
in the cache.  Therefore, those methods could be configured to expand
a home directory via a connection property, *Note Predefined
connection information::.  Example:

     (add-to-list 'tramp-connection-properties
                  (list (regexp-quote "/sshfs:user@randomhost.your.domain:")
                        "~user" "/home/user"))

   When your remote file name does not contain a ‘user’ part, the
connection property "~" must be used instead.
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]