I have the following in my .emacs:
(require 'tramp)
(setq tramp-default-method "plink")
When I run C-x C-f /plink:some_session:/
in Emacs where some_session
is a defined session in PuTTY (which has all information saved such as location of private key, username, connection type=ssh, etc.), tramp issues the following command (copied from *Messages* buffer):
Tramp: Sending command ‘plink -ssh -t some_session " env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ ' /bin/sh " && exit || exit’
You can see that it passes the -ssh
flag to plink
. Everything works fine when I am connecting to a remote host which expects the ssh connection on port 22.
However, I have a remote host which I need to connect to on port 2222. If I save a session (some_new_session
) in PuTTY and try to connect using the following commands (or the PuTTY gui) this is what happens:
plink some_new_session
cmd.exe
- works fine and am able to connectplink -ssh some_new_session
cmd.exe
- does not workI have debugged the issue and found that when the -ssh
flag is passed to plink
it attempts to connect on port 22 anyway even though the saved session states to use port 2222. Essentially when given -ssh
it ignores the port saved in the session (which feels like a bug).
If I try to connect using C-x C-f /plink:some_new_session:/
in Emacs the command issued is:
Tramp: Sending command ‘plink -ssh -t some_new_session " env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ ' /bin/sh " && exit || exit’
I actually do not need the -ssh
flag because the connection type being SSH is saved in the PuTTY session. Also the -ssh
flag forces the connection to be through port 22 even though the session has it saved as port 2222.
My question is:
How can I change the command issued by tramp so it does not call plink with the -ssh flag?
The plink
method is intended to use a hostname. If you want to (reuse) a session, use plinkx
, like C-x C-f /plinkx:some_session:/
and C-x C-f /plink:some_new_session:/
.