How can I use ssh with Emacs on Windows - emacs

I have a Windows developer workstation with Emacs installed and Linux server with source files and SSH server. How can I open source files on Emacs?
I have tryied:
C-x C-f /ssh:user#host#22:/home/user/file.rb
but got unreadable error message.

I think you need TRAMP for Emacs:
After the installation of tramp into your Emacs, you will be able to
access files on remote machines as though they were local. Access to
the remote file system for editing files, version control, and dired
are transparently enabled.
The package provides support for ssh connections out of the box, one
of the more common uses of the package. This allows relatively secure
access to machines, especially if ftp access is disabled.
Under Windows, tramp is integrated with the PuTTY package, using the
plink program.
For more info:
http://www.gnu.org/s/tramp/#Overview
PS: Copying and pasting the "unreadable error message" would certainly be useful.

Related

Is there any extension in Visual Studio Code , which is similar to Tramp Mode in Emacs?

TRAMP (Transparent Remote Access, Multiple Protocols) is a package for editing remote files, similar to AngeFtp or efs. Whereas the others use FTP to connect to the remote host and to transfer the files, TRAMP uses a remote shell connection (rlogin, telnet, ssh). It can transfer the files using rcp or a similar program, or it can encode the file contents (using uuencode or base64) and transfer them right through the shell connection.
It seems like as of now there is at least one similar package to Tramp mode for VSCode. I couldn't directly find in the documentation how you would open a remote shell inside VSCode, but it seems like it would have to be possible given the rest of the plugin.
https://code.visualstudio.com/docs/remote/ssh
https://code.visualstudio.com/blogs/2019/10/03/remote-ssh-tips-and-tricks
I have a terminal menu in VSCode that I can open up and directly ssh to stuff, so that seems to cover both sides of the "Tramp" mode usage
You can use FUSE for a somewhat similar effect. It's not editor specific, but mounts remote file systems via SSH, FTP and whatnot directly to your local file system so you can use it with any Editor.
You didn't mention on what operating system you, but here's the link to the version for macOS: https://osxfuse.github.io

Tramp can not connect to remote server

I have upgraded my emacs and updated some el-get packages including tramp (my system is a bit old, and I could not upgrade some emacs packages), and now I can not use tramp to connect to a remote server:
Tramp: Opening connection for server1 using ssh...failed
byte-code: Host `server1' looks like a remote host, `ssh' can only use the local host
I am using tramp version 2.2.13-pre and emacs version 24.5.1. I have compiled emacs myself, in case it matters.
What can be going wrong? What could I try?
EDIT
I am calling tramp like this:
C-x C-f /user#server1:filename
Call emacs -Q. Likely, Tramp will work then. In this case, bisect your .emacs file and restart Emacs, until you find the package which causes the trouble.
One package which didn't cooperate well with Tramp was projectile. Disable it, when you are using it.

Accessing local emacs from PuTTY

My school (UCSB) has us use PuTTY to remotely access our CS account that's ran on the school's server. Whenever I attempt to use the school's emacs via PuTTY, it's extremely tedious because it's all in text user interface. I do have an option to use Xming to access the GUI Emacs, but that's incredibly slow since it still relies on the server's emacs. So now I'm fed up of relying on using WinSCP as a text-editor (I know it isn't suppose to be a text-editor) on my laptop, and want to use emacs without the terrible interface or speed. I finally went to the GNU website to download a local copy of emacs on my laptop. However I can't do anything with it unless I constantly transfer my files from the school's server to my laptop for editing, and vice-versa for compiling, which can be very tedious.
So, is there a way I can use PuTTY to access the files on my school's account and then have them opened using my local emacs? Or is there any other ideas or tools to help me with my situation?
TRAMP would be the way to go. In order for TRAMP to use PuTTY by default do this
(setq tramp-default-method "plinkx")
After that you can access the files or use dired on your remote host by using paths like
/name_of_Putty_session:/path/on/remote/host

Open remote Server Files in local emacs

I used to be a comfortable emacs user and for close to 10 years I completely got away from using emacs (I know its a shame) but I have a wage memory of setting something in .emacs to open remote files in a server via local emacs.
Just to make the scenario clear:
Login to a remote server (ssh) -> emacs somefileInRemoreServer.file &
File get open using the local version of emacs.
My questions are:
Is this possible?
how can I accomplish this?
I have both mac and ubuntu on mac I use Aquamacs. It would be a great help if I can get instructions on both versions.
I'm not sure whether you want to ssh prior to using emacs or ssh using (in) emacs.
If you want to let emacs do all the work check out the links added by phils, TRAMP mode is the way to go for remote editing IN emacs.
If you want to use ssh to mount a remote filesystem (resulting in "local" editing with emacs) you should check out sshfs (man, wiki).
I think it comes with pretty much any of the current distros (or can be installed easily otherwise). It is a fuse extension which allows to mount a remote directory to a local one without any further requirements on the remote side than ssh.
I do like TRAMP for editing one or two files but using sshfs is great for working on a whole project directory which is placed remotely and which you do not want to sync using another method.

Using a single emacs instance from multiple (virtual) machines

I love emacsclient. It allows me to use a single Emacs frame for all my editing, also when programs want to open an editor (i.e. export EDITOR=emacsclient).
I'd like to have it work like this with virtual machines, too. I can use tramp to edit remote files with Emacs in my single-frame setup, and it works very well, but it's not enough. When I invoke git commit or sudoedit, I'll have to use the crappy terminal-based editor that happens to be installed on the remote machine.
So, is there anything like emacsclient that works across multiple machines?
Speculation: If you can ssh from the VM back to your local machine then the VM could probably invoke emacsclient on your local machine, with the appropriate tramp prefix to the remote file? Set up a script for that, and configure your remote EDITOR environment variable to match.
It could be you can do more with TRAMP than you think. First off, you may have noticed that /sudo: doesn't work for remote boxes, but TRAMP allows you to proxy to a remote box and then use any supported protocol, so in effect you can use /sudo: on a remote box. See tramp-default-proxies-alist.
You mentioned invoking git commit on a remote box. Have you considered using one of the Emacs git interfaces such as magit? They will work through TRAMP as well.