---
title: "Using Emacs Tramp For SSH (Emacs SSH)"
description: "The Emacs \"Tramp\" functionality brings the power of SSH into your text editor. You no longer need to open a separate terminal window in order to run scripts, edit files, or perform other server..."
url: https://www.inmotionhosting.com/support/edu/emacs/emacs-tramp/
date: 2020-12-29
modified: 2022-02-21
author: "Christopher Maiorana"
categories: ["Emacs"]
type: post
lang: en
---

# Using Emacs Tramp For SSH (Emacs SSH)

![Emacs Tramp | Easy SSH Inside Emacs](https://www.inmotionhosting.com/support/wp-content/uploads/2020/12/Emacs-Tramp-1024x538.png)

Experience full control over your server environment and deploy the best operating and management systems that fit your needs with our reliable [Cloud VPS Hosting](https://www.inmotionhosting.com/cloud-vps)!

The Emacs “Tramp” functionality brings the power of SSH into your text editor. You no longer need to open a separate terminal window in order to run scripts, edit files, or perform other server maintenance. Tramp lets you do it all right inside of an Emacs buffer. Additionally, Tramp is built into Emacs, so you do not need to install any additional software or plugins.

- [Emacs Tramp Brings Your Server Into Emacs](#ssh-from-emacs)
- [How To Use Emacs Tramp](#how-to-use-tramp)
- [Emacs Sudo Issues and SSH Privileges](#sudo-privilege)

## Emacs Tramp Brings Your Server Into Emacs

There are only two things you would ever need to do in your server:

- Edit files
- Run scripts

These tasks can be easily accomplished with a basic terminal emulator and SSH. You can log into your server, run scripts, edit files, and do all the work you need to do. But with Emacs, you don’t need a terminal emulator to do these things. Likewise, you can carry your local Emacs configuration into whatever server you visit.

### How Tramp Works

When you are prompted to open a file or directory in Emacs, you can instead add an access method to the directory path. In this article, I will use SSH, but there are others.

Behind the scenes, invisible to the user, Emacs establishes a connection to the server and allows you to access files as though they were located on your local computer.

This means you can bring all of your Emacs configurations and expressions with you during your server login session. You can also seemlessly switch back and forth between local and remote buffers; as you probably know, copying and pasting text to and from text-based terminals can be an annoying chore — not so in this instance.

## How To Use Emacs Tramp

Tramp works alongside [dired](https://www.inmotionhosting.com/support/edu/emacs/dired/) to give you the same functionality remotely as you enjoy locally. All you need to do is construct the directory path differently. But basically you are using the `find-file` function (or, `C-x C-f`) as normal.

In order to open a Tramp buffer just type `C-x C-f` and append the “ssh:” method to a directory path:

/ssh:root@example.com:~/

Of course, replace “example.com” with your domain name. If you wait a moment for the connection to be established, you will be prompted to unlock your SSH key, and asked if you would like to save your autentication information. Then you will be brought into a dired window displaying the files and directories in your server’s home folder for the `root` user.

## Emacs Sudo Issues and SSH Privileges

Your Tramp session inherits whatever privileges belong to the user you logged in as. If you log in as the `root` user, you have complete access to your server.

Otherwise, you would need to pass sudo privileges into your session:

/sudo::/path/to/file

Even simpler, if your user does not require superuser privilege in order to complete the desired operations then you don’t need to pass `sudo` into your access method.

Check out other Emacs resources:

- [Learn about Emacs helper function](https://www.inmotionhosting.com/support/edu/emacs/helper-functions/)
- [Read Emacs Dired documentation online anytime](https://www.gnu.org/software/emacs/documentation.html)
- [The GNU philosophy](https://www.gnu.org/philosophy/philosophy.html)
- [Emacs and Vim compared side by side](https://www.inmotionhosting.com/support/edu/emacs/choosing-emacs-vs-vim/)
- [How to wrap text in Emacs](https://www.inmotionhosting.com/support/website/software/how-to-wrap-text-in-emacs/)
- [Doom Emacs](https://www.inmotionhosting.com/blog/doom-emacs-for-vim-users/)
