Skip to main content

SSH

SSH, which stands for Secure Shell, is a secure protocol that facilitates remote access to your Repl's command line interface. With SSH, you can seamlessly transfer files and leverage your preferred local Integrated Development Environment (IDE) for editing code on Replit, enhancing collaboration and productivity in your development workflow.

SSH functionality is available in all of the Replit paid plans.

Here's an overview of the process:

  • you will need to generate a public SSH key on your local machine
  • you will need to add that SSH key to the Repl you want to connect to
  • run SSH on your local machine to connect to your Repl (or configure your editor to SSH into the Repl)
note

SSH is configured at the account level, not at the Repl level. This means that when SSH is configured for your account, you can access all the Repls within your account.

Real-time Repl and editor synchronization features

  • Automatic updates between Repl and editor: Any changes made in the Repl are reflected in your editor instantly, and any modifications in the editor are updated in the Repl. This seamless synchronization ensures that your codebase is always up-to-date across platforms.

  • File management synchronization: Whether you add, delete, or update files, these changes are synchronized in real time between your editor and the Repl. This feature ensures that your project structure remains consistent, regardless of where the changes are initiated.

  • Folder management and file moving: Moving files across folders is also synchronized between your editors and the Repl. This ensures that organizational changes made in one environment are accurately reflected in the other, maintaining the integrity and structure of your project.

Mac/Linux

Using an existing public key

To configure SSH for your account, you'll need your SSH public key. You can check if you already have a public key by running the following command:

ls -l ~/.ssh

Look for a file with the .pub extension in the output, representing your public key. You can display its content using this command:

cat ~/.ssh/replit.pub

Save the above command's output to use later in this article. Now, proceed to Step 2 to add the public key to your Repl.

Generating and adding an SSH key

Step 1: Generate an SSH key

In your machine, open the terminal and paste the following command to generate an SSH key:

[ -s ~/.ssh/replit.pub ] || ssh-keygen -t ed25519 -f ~/.ssh/replit -q -N "" && cat ~/.ssh/replit.pub

This command checks if a specific SSH public key file already exists. If not, it creates a new SSH key without a password and shows the new public key.

Copy the output from your terminal, which looks similar to the following, then proceed to the next step:

sh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEWU6rRytWZVA68grroCjbS8pwVaoY1WV69TiYCcg7zu your_email@example.com

Save the output to use it in the next section of this article.

Step 2: Add the SSH key to your account

  1. In your Repl on any window, select the + button, then search for SSH.
  2. Navigate to the Keys tab and select New SSH key.
  3. In the popup window, enter a Label for your key (e.g., my-ssh-key) and paste the public key you copied into the Key section. Select the Add SSH Key button. Your key has been added and authorized for use.

Alternatively, you can add an SSH key by navigating to your Account and selecting SSH keys.

Use the Add SSH key button and follow the steps in the above section Step 2 to add the SSH key to your account.

note

When you have multiple public keys on your machine, it's important to ensure that you use the correct combination of private and public keys for your SSH configuration.

Windows

On Windows, you have two options to generate SSH keys:

Using PuTTYgen: You can use PuTTYgen to generate SSH keys. When you create or load an existing key in PuTTYgen, the public key will be displayed in the "Public key for parsing..." section, which you should then paste into the "SSH" pane in your Replit settings.

  • You can install OpenSSH and use ssh-keygen and the ssh commands in the Windows terminal. The process is similar to generating and using keys on Mac and Linux.

Connect your Repl to VS Code

Step 1: Update SSH configuration

  1. In the SSH window, navigate to the Connect tab and select Launch VS Code.
  2. You'll be prompted to update your SSH configuration. Open the SSH config file in your preferred text editor. This file is usually located at ~/.ssh/config.
  3. Add the following configuration to the config file:
    Host *.replit.dev
    Port 22
    IdentityFile ~/.ssh/replit
  4. Save the changes to your config file.
note

Adding SSH configuration is only prompted the first time you are trying to connect to VS Code or another editor.

Step 2: Launch VS Code

  1. Return to your Repl and confirm you've updated your configuration by selecting the button I updated my config.
  2. If prompted by an external application warning, select Yes to confirm you want to open your project in your preferred editor or VS Code.
  3. You should now see your Repl open in VS Code.
note
  • Ensure your browser has the required disk permissions to launch the editor. If you encounter errors, check your browser's permissions in your system's preferences.
  • If you encounter errors when launching VS Code, it may be necessary to install the SSH VS Code extension and then reload the application.

Test SSH configuration

Use the following methods to verify the SSH connection.

After setting up your SSH key, you can connect to your Replit environment using the following methods:

Quick-connect SSH command

You can directly connect SSH to your Replit environment using the following command. No additional configuration on your machine is needed:

ssh -i ~/.ssh/replit -p <port_number> <your_username@your_hostname>.<cluster>.replit.dev

Once you replace the above command with your details, the command should look like:

ssh -i ~/.ssh/replit -p 22 c96b6ade-d5e4-4f7a-bc5b-52334509b2a3@c96b6ade-d5e4-4f7a-bc5b-52334509b2a3-00-16nh2hskw3ql8.riker.replit.dev

Some examples of clusters include riker, spock, janeway, and picard which may change based on requirements.

SSH client configuration

Numerous SSH clients are available, some of which are equipped with graphical interfaces like PuTTY (for Windows) or Termius (for Mac). You can configure your SSH key with the following values:

Hostname: <your_hostname>.<cluster>.replit.dev

Port: <port_number>

For example:

Hostname: c96b6ade-d5e4-4f7a-bc5b-52334509b2a3-00-16nh2hskw3ql8.riker.replit.dev

Port: 22

Was this helpful?