[emacs-berlin] Tramp mode with custom location for SSH config

jman emacs-berlin at city17.xyz
Sun Mar 12 10:13:03 UTC 2023


Thank you Michael for the help :)

> tramp-set-completion-function is used for host name completion only. It
> doesn't change anything how Tramp calls ssh.

Ok, now I understand what is happening (though I don't have clear why
the SSH config file is used only to read hostnames ignoring all the rest).

> Alternatively, you could add an own method to `tramp-methods' which adds
> the "-F ~/.config/ssh/config.d/config.whatevs" option to the ssh call.

It works great! For the record, I have added the following
snippet to my Emacs config:

--8<---------start----------x--------->8--
(add-to-list 'tramp-methods
             '("ssh-j" ;; LOL slight variation for the "ssh" method
               (tramp-login-program "ssh")
               (tramp-login-args
                (("-F" "$XDG_CONFIG_HOME/ssh/config")
                 ("-l" "%u")
                 ("-p" "%p")
                 ("%c")
                 ("-e" "none")
                 ("%h")))
               (tramp-async-args
                (("-q")))
               (tramp-direct-async t)
               (tramp-remote-shell "/bin/sh")
               (tramp-remote-shell-login
                ("-l"))
               (tramp-remote-shell-args
                ("-c"))))
--8<---------end----------x--------->8--

Just one minor wrinkle since I am not great lisper. For the additional
"-F" parameter I wanted to use:

--8<---------start----------x--------->8--
("-F" (concat (getenv "XDG_CONFIG_HOME") "/ssh/config"))
--8<---------end----------x--------->8--

it is successfully evaluated (C-x C-e), but then TRAMP returns this error:

(wrong-type-argument "char-or-string-p (concat (getenv XDG_CONFIG_HOME) /ssh/config)"

Why?


More information about the emacs-berlin mailing list