I often connect to remote servers using tramp to do some work, however sometimes after editing files I need to connect using PuTTY in order to do some specific task.

At the moment I open up PuTTY, and type the user and server names in. It seems to me that tramp already has that information and I should be able to run an Emacs command that extracts tramp connection details for the current buffer and runs PuTTY for me. I can't work out how to get this information, though.

Note: I can't just run commands over the tramp connection (eg, with M-!) as it may require variables set up in the .profile.

  • Have you tried executing M-x shell and opening a shell on the remote host inside emacs?
    – InHarmsWay
    Dec 14, 2017 at 14:19

1 Answer 1


You might try it the other way. Create a PuTTY session with all information you need (user name, host name, etc). You could use this PuTTY session with "/plinkx:sessionname:" then. You could even share the connection between Emacs/Tramp and the native PuTTY connection.

  • I don't think I've described what I'm trying to do very well. I'm really lazy and can't be bothered retyping the username and servername (or session name) when I run PuTTY, so I was wondering if there's a simple way of getting that from tramp. I guess I could just extract it using a regexp. (Thanks for all your work on tramp, btw, it's fantastic!)
    – Alan Third
    Aug 17, 2017 at 8:35
  • 2
    In this case, try (file-remote-p default-directory 'user) and (file-remote-p default-directory 'host). Aug 17, 2017 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.