I've accessed a server through the ssh mode in Emacs. I need to create and save a file on the server. I can open a file through nano <filename> and start to type. However, I'm unable to close & save the file. Nano states that I should use C-x to close but that key sequence is interrupted by Emacs which waits for a further command & I can't find anyway to enter C-x as an alternative.

Is there a way to do this?

  • Not quite sure what ssh mode is. It sounds like you're opening either term, shell, or eshell and then sshing to a remote host. It's important to know which for further help. Also, you should look into tramp (quick answer: C-x C-f /ssh:user@host:/path/to/file).
    – jpkotta
    Commented Feb 5, 2018 at 23:38
  • Hello. How I enter this mode is by using the command 'M-x ssh RET'. I then have to type in the hostname and password.
    – zhanmusi
    Commented Feb 6, 2018 at 9:20
  • I'm not able to check now because I think I downloaded it through the internal emacs package manager and I haven't my laptop. But I think this is the mode that I'm using: hiroom2.com/2017/04/18/emacs-ssh-mode-package
    – zhanmusi
    Commented Feb 6, 2018 at 9:28

1 Answer 1


If ssh-mode is based on shell (and it seems like it is), nano (or vim or any terminal-based editor) is not going to work well. Same with eshell. It seems like you can type control characters with C-q (quoted-insert), e.g. C-q C-x RET for C-x.

You're better off with term, because it's actually a terminal emulator (shell and eshell are not). Just M-x term, run ssh in there, and do what you want. Note that a lot of Emacs keybindings are different in term; switch to term-line-mode (C-c C-j) to make it more like a normal buffer and get your keybinds back.

You're even more better off with tramp, because it makes editing remote files almost seamless.

  • The quoted-insert solution worked for the immediate problem but I found that ssh mode still had problems working with 'nano' remotely. Ultimately I ended up diving into tramp and found that it worked well with editing files remotely. My recommendation for anyone else reading this answer is to learn how to use tramp. Thanks jpkotta!
    – zhanmusi
    Commented Feb 7, 2018 at 2:06

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.