Skip to main content

Visual Studio Code SFTP Extension

Learn how to upload local changes with Visual Studio Code's SFTP extension.


This section provides information on how to upload local changes in Visual Studio (VS) Code.

Before You Begin

  1. Create a site on Pantheon, or browse to the Dev environment Dashboard of an existing site.

  2. Use SFTP, rsync, or Git to clone your site files on the Dev environment down to your local machine.

    You must place your site code in a subdirectory called code (for example, ~/sites/mysite/code) to upload code changes via SFTP. This aligns with the file structure on the platform when using SFTP mode.

  3. Download and install VS Code.

  4. Create a VS Code Workspace.

Upload your Changes with SFTP

The SFTP extension for VS Code allows you to upload code to the Pantheon Dev or Multidev environment directly from VS Code, as well as download files from the Pantheon servers to your local machine.

  1. Verify that your site is in SFTP mode before uploading code via SFTP.

  2. Install the VS Code SFTP Extension.

  3. Open the VS Code command palette (Ctrl/Command + Shift + P) and run SFTP: config to open the SFTP config file.

  4. Edit the file using the connection information from your Site Dashboard, under the Connect with SFTP button in Development Mode. Remove the remotePath line, as the path is subject to change and you'll be automatically directed to the correct location:

    sftp.json
    {
        "name": "My Site",
        "host": "appserver.dev.YOUR-SITE-UUID.drush.in",
        "protocol": "sftp",
        "port": 2222,
        "username": "dev.LOGIN-UUID",
        "uploadOnSave": true
    }
  5. Include the path to your SSH Key if you have one added to your Pantheon account. If you aren't using a key, you'll be prompted to enter a password when using SFTP. Refer Dashboard Credentials for more information.

    sftp.json
    {
        "name": "My Site",
        "host": "appserver.dev.YOUR-SITE-UUID.drush.in",
        "protocol": "sftp",
        "port": 2222,
        "username": "dev.LOGIN-UUID",
        "uploadOnSave": true,
        "privateKeyPath": "/Users/localUser/.ssh/id_rsa"
    }
    Warning:
    Warning

    You must convert your key to PEM format if you use an RSA key and get the following error:

    Error while signing data with privateKey: error:06000066:public key routines:OPENSSL_internal:DECODE_ERROR

    Run the code below to convert your key:

    ssh-keygen -p -m PEM -f ~/.ssh/id_rsa

    This may have unintended consequences if you're using this key to authenticate to other systems. We recommend making a new key specifically for this application to convert.

    Refer to this issue on the vscode-sftp plugin GitHub repo for more information.

  6. Set uploadOnSave to true. The next time you save changes to a file it will automatically be pushed to Pantheon.

  7. Commit your files to Git using the Pantheon Dashboard.

More Resources