How to Edit Remote Files over SSH: 4 Easy Methods

Knowing how to edit remote files over SSH is essential when managing a Linux server. Whether you need to update an environment variable, adjust an Nginx configuration or change a Docker Compose file, you do not have to manually download the file, edit it and upload it again.

Several tools let you work directly with remote files. Some run inside a terminal, while others provide a graphical editor on your desktop.

This guide covers four methods: Nano, Vim, VS Code Remote SSH and Server Explorer. It also explains how to avoid common mistakes when editing production files.

Before you edit a remote file

You need the server’s IP address or hostname, its SSH port, an authorized username and a password or SSH key. Your account must also have permission to read and modify the target file.

For the terminal-based methods, open a terminal on macOS or PowerShell on Windows and connect:

ssh deploy@your-server-ip

For a custom SSH port, use:

ssh -p 2222 deploy@your-server-ip

Verify the server’s host key fingerprint through a trusted source when connecting for the first time. If you are new to remote connections, read our guide on connecting to a Linux server from Windows without PuTTY.

1. Edit remote files with Nano

Nano is a straightforward terminal text editor. It is a good choice when you need to make a small configuration change without learning complex keyboard shortcuts.

After connecting to your server, open a file:

nano /var/www/app/config.yml

Use the arrow keys to navigate and type your changes. To save and exit:

  1. Press Ctrl+O to write the file.
  2. Press Enter to confirm the filename.
  3. Press Ctrl+X to close the editor.

For a protected configuration file, an authorized sudo user can use:

sudoedit /etc/nginx/nginx.conf

This uses your configured editor to modify a temporary copy before writing the changes back with elevated permissions. To select Nano specifically, use SUDO_EDITOR=nano sudoedit /etc/nginx/nginx.conf if your sudo policy permits it.

Nano is convenient for occasional edits. However, navigating several directories and working across many files can become cumbersome.

2. Edit remote files with Vim

Vim is another terminal-based editor, particularly useful for developers who already know its commands. It provides powerful search, navigation and editing capabilities without requiring a graphical interface on the server.

Open a remote file from your SSH session:

vim /var/www/app/config.yml

Follow these steps:

  1. Press i to enter insert mode.
  2. Make your changes.
  3. Press Esc to return to normal mode.
  4. Type :wq and press Enter to save and exit.

To quit without saving, use :q!. To search for a setting, type / followed by the search term and press Enter.

Vim works well over slow connections and is suited to frequent terminal users. Its main drawback is the learning curve: basic operations require familiarity with its editing modes.

3. Edit remote files with VS Code Remote SSH

VS Code Remote SSH is useful when your goal is to work on an entire remote codebase rather than change a single configuration file.

To get started:

  1. Install Visual Studio Code on your computer.
  2. Install the Remote – SSH extension from Microsoft.
  3. Open the Command Palette and select Remote-SSH: Connect to Host....
  4. Enter your SSH connection details or select a configured host.
  5. Once connected, open the remote project folder.
  6. Edit and save files using the familiar VS Code interface.

The extension installs a VS Code Server component on the remote machine. Your server must meet its requirements and have enough available resources to run it.

Features such as project-wide search, Git integration and compatible remote extensions make this approach attractive for development work. For occasional server administration, though, a dedicated SSH file editor may be a simpler option.

4. Edit remote files with Server Explorer

Server Explorer is a desktop SSH client for macOS and Windows that combines remote file management with server administration tools.

Instead of opening a separate terminal editor for every change, you can browse the server’s directories and open configuration files within the same workspace.

Browse the remote filesystem

  1. Launch Server Explorer and add your Linux server using its SSH connection details.
  2. Connect and open the File Explorer.
  3. Navigate to the directory containing your file, such as /var/www/app/.

The visual file browser helps you locate configuration files when you do not remember their exact paths.

Remote SSH file explorer in Server Explorer.
Browse remote Linux files directly from Server Explorer’s integrated file explorer

Modify and save a configuration file

  1. Open a file such as docker-compose.yml in the integrated editor.
  2. Locate the setting you want to update.
  3. Make the required changes and save the file.

The integrated editor provides syntax highlighting, making structured configuration files easier to read. There is no need to manually manage a separate download and upload workflow.

Edit remote files over SSH with Server Explorer.
Edit remote configuration files over SSH using Server Explorer’s integrated code editor

Your SSH account still needs the appropriate filesystem permissions. A graphical editor does not bypass Linux access controls.

Check the result without switching applications

Saving a configuration file is only part of the job. Depending on the application, you may also need to validate its configuration, reload a service or inspect logs.

Server Explorer brings the terminal, file browser and other administration tools together. For example, after updating a Compose file, you can use the integrated terminal in the project directory to run:

docker compose config --quiet

This checks the Compose configuration without printing its resolved contents. A successful check does not automatically apply the changes or guarantee that the application will run correctly.

For more context on combining graphical tools with terminal commands, see our server management GUI vs CLI guide.

Compare remote SSH file editors

ToolInterfaceBest for
NanoTerminalQuick configuration changes
VimTerminalExperienced command-line users
VS Code Remote SSHGraphical IDERemote software development
Server ExplorerGraphical SSH workspaceDaily server administration

Nano and Vim require the corresponding editor on the remote server. VS Code Remote SSH requires a compatible remote server component. Server Explorer’s file editing workflow uses SSH and does not require a general management agent.

Choose the tool according to the task rather than assuming one editor is best for every situation.

server_explorer_cta

How to edit remote files safely

Back up important configuration files

Before changing a production configuration, keep a recoverable copy in an appropriately protected location. For an ordinary, user-owned configuration file, you can create a backup with:

cp -p config.yml "config.yml.backup-$(date +%Y%m%d-%H%M%S)"

Run this in the directory containing the file. Keep backups outside publicly served directories, particularly if they contain credentials. For sensitive files, use your existing secure backup process instead.

Respect Linux file permissions

If saving fails with a permission error, inspect the file and its parent directory:

ls -l /var/www/app/config.yml
ls -ld /var/www/app

Avoid using chmod 777 as a quick fix. Use an authorized account, correct ownership through your administrator or use sudoedit for protected system files where appropriate.

Validate changes before reloading services

For example, after updating an Nginx configuration, test it first:

sudo nginx -t

Only if the test succeeds, reload Nginx on a systemd-based server:

sudo systemctl reload nginx
sudo systemctl status nginx

Check that the application still responds as expected. If the change causes a problem, restore the known-good configuration, validate it again and reload the service.

Keep secrets and deployment workflows in mind

Never publish screenshots containing real API keys, passwords or tokens. Avoid editing generated or deployment-managed files directly when they will be overwritten by the next release. For application code, prefer changes through version control and your established deployment process.

Conclusion

You can edit remote files over SSH using a simple terminal editor, a full development environment or a dedicated server management application.

Nano is suitable for small changes, Vim offers powerful terminal editing, and VS Code Remote SSH works well for remote projects. Server Explorer provides an alternative for administrators who want file editing, terminal access and infrastructure tools in one desktop workspace.

server_explorer_cta

Leave a Reply

Your email address will not be published. Required fields are marked *