Curiouser and curiouser ...

I did have the host in my ~/.ssh/config file -- with the wrong ip address
and the wrong path to the key. (Nevertheless, Tramp had worked for years
....)

So I fixed that, and can now connect from the command line via ssh <foo>,
as one would expect (I had been using an aliased command).

However, Tramp works only if I supply the username in the connect
string: (find-file "/ssh:<user>@<foo>:/home/<user>/<file>" t)

If I don't, it uses a wrong name from 'tramp-default-user-alist, and the
connection fails. Even if I remove that name from .emacs and reload, Tramp
still uses that name, so it must be getting it from elsewhere -- it's not
my local machine username, but the name that goes with an entirely
different remote server.

Clearly, I need to read the documentation -- but now the question (much
less important) is, How did I ever get this to work in the first place?

Thanks!
Fred

On Sat, Oct 26, 2019 at 9:20 AM Michael Albinus <[email protected]>
wrote:

> Frederick Bartlett <[email protected]> writes:
>
> Hi Fred,
>
> > Here's your shell experiment (same result as from inside Emacs):
> >
> >     $ ssh -l ec2-user  -o ControlMaster=auto -o ControlPath='tramp.%C'
> >     -o ControlPersist=no -e none xx.xxx.xxx.xxx
> >     [email protected]: Permission denied
> >     (publickey,gssapi-keyex,gssapi-with-mic).
> >
> > And here's my usual ssh command (which works):
> >
> >     ssh -i <path_to_public_key_file> -o ServerAliveInterval=5 -o
> >     ServerAliveCountMax=1 [email protected]
>
> The difference is "-i <path_to_public_key_file>". Is it located
> somewhere else but in ~/.ssh? An unusal name? And is it really a public
> key file? Ususally, "-i" specifies the identity (private key) file.
>
> > Could I edit the Tramp command in Emacs to include a reference to
> > public key?
>
> Sure. Have a look at tramp-methods. There is an entry like
>
> --8<---------------cut here---------------start------------->8---
>  ("ssh"
>   (tramp-login-program "ssh")
>   (tramp-login-args
>    (("-l" "%u")
>     ("-p" "%p")
>     ("%c")
>     ("-e" "none")
>     ("%h")))
>   (tramp-async-args
>    (("-q")))
>   (tramp-remote-shell #1#)
>   (tramp-remote-shell-login
>    ("-l"))
>   (tramp-remote-shell-args
>    ("-c")))
> --8<---------------cut here---------------end--------------->8---
>
> You could overwrite the tramp-login-args element, via a connection
> property "login-args". Consult the docstring of tramp-methods for the
> meaning of the %x templates. And consult the Tramp manual about
> connection properties at (info "(tramp) Predefined connection
> information")
>
> Alternatively, you could add an entry in your ~/.ssh/config like this:
>
> --8<---------------cut here---------------start------------->8---
> Host foo
>         HostName        xx.xxx.xxx.xxx
>         User            ec2-user
>         IdentityFile    /path/to/identity/file
> --8<---------------cut here---------------end--------------->8---
>
> With this, you can use Tramp via "/ssh:foo:". And also in your shell,
> you can call directly "ssh foo".
>
> > Thanks,
> > Fred
>
> Best regards, Michael.
>

Reply via email to