Search code examples
emacssudotramp

Emacs "Tramp" sudo setup in authinfo.gpg : machine specific sudo accreditation


I have a bookmark for a remote file over ssh thus:

/ssh:remoteuser@remote-server|sudo:remoteuser:/etc/apache2/apache2.conf

After much messing around this entry in my authinfo.gpg file allowed tramp toprovide the sudo password for "remoteuser" on the remote-server:

machine remoteuser port sudo login root password remote-user-sudopassword

The problem I have is that this authinfo line isnt specific to remote-server : the host/machinename is in fact the remoteuser id. What does this mean? It means that the sudo password for "remoteuser" must be the same on all machines where remoteuser operates. Is there some alias/mapping i can do in auth-sources/tramp to enable me to have different authinfo lines for tramp sudo accreditation for "remoteuser"?


Solution

  • Your remote file name is wrong. It must be

    /ssh:remoteuser@remote-server|sudo:remote-server:/etc/apache2/apache2.conf
    

    That is, the host name in both parts of the file name must be the same. This would change your .authinfo.gpg entry to

    machine remote-server port sudo login root password remote-user-sudopassword
    

    Note, that in the upcoming Emacs 27.1 (containing Tramp 2.4) it will be checked that the host names in such a multi-hop match.