There are various ways to do this, but in generally you are going about this problem backwards. Copy your emacs configs to the remote machine and use emacs local to the files you are editing.
The "various ways to do this" would fall into two categories. First would be ways of mounting a remote drive locally through something like sshfs, some fuse file system, samba, nfs, or any number of other mounting systems to bring file level access to your machine. Second would be various programs that allow you to login and browse a remote system, then operate on files by transferring a copy of them to a local temp file, editing it, then transferring it back. Several programs make that process look pretty seamless, but it's a hack.
I worked out an approach that lets you find out specifically what terminals are available on the remote host and then set it. Usually, there is at least one ansi compatible terminal, so a 'hack' to fake it should be unnecessary.
Done in one long'ish ssh command, it will look something like this:
ssh -i ~/.ssh/some_key.pub -tty some_remote_server "export TERM=`ls -1R /usr/share/terminfo | grep ^eterm-color$ || ls -1R /usr/share/terminfo | grep ^aterm$ || ls -1R /usr/share/terminfo | grep ^ansi$ || ls -1R /usr/share/terminfo | grep ^xterm-256color$ || export TERM=xterm && emacs -nw"
This finds different ansi compatible (and non-compatible) terminal types in an order of preference on the remote host and sets the first one found before launching EMACS. It sets TERM to use 'xterm' type if none of our preferred types are found, ensuring EMACS does actually launch.
In this example, I am looking for eterm-color, aterm, ansi, and xterm-256color in that order. I am not a heavy EMACS user, so not sure those are actually the best. I tested this launch on CentOS and worked well (it found eterm-color in my testing).
I believe the terminfo is in the same place on most/all Linux variants, but you can add more paths to search the same way you would add more terminals, by adding more
|| ls -1R /a/different/path | grep ^someotherterminal$
conditional test and pipes.
Best Answer
The value of the
TERM
environment variable should be the same on both systems.