Help Center

Connect Visual Studio Code to cPanel using SSH

Connecting Visual Studio Code to your service on cPanel is simple using the Remote SSH plugin.

If you haven't installed this useful plugin in VSC yet, all you need to do is go to the last icon on the left side (Extensions) or press Ctrl + Shift + X and search for "Remote - SSH".

Once the plugin is installed, you can continue with this guide.

Creating a Connection Key from Windows

To get started, you need to open your terminal (CMD) on your computer and type "ssh-keygen".

You will be prompted to enter the key name. You can name it whatever you like.

Next, you will be asked to enter a "password" or passphrase twice. We recommend leaving it blank and pressing Enter both times.

You can navigate to the directory "C:\Users\YOUR_USER\.ssh" where you’ll see two files created (your public and private keys).

Finally, open both files with any text editor and copy the content... now, let's go to cPanel!

Import Key into cPanel

Now, go to cPanel, select "SSH Access" and then "Manage SSH Keys". Click the "Import Key" button.

Choose the same name you assigned in CMD and import both the private and public keys by copying and pasting the text (the public key will have a .pub extension).

Lastly, under the public keys section, click "Manage" and then click the "Authorize" button.

You’re now ready to connect.


Generate Key in cPanel

Log in to cPanel and search for "SSH", then click on "Manage SSH Keys".


Click the "+ Generate a new key" button and fill out the form:
  1. Give your key a name.
  2. Set a password.
  3. Click "Generate Key".
  4. Click "Manage" to authorize the key, then select "Authorize".


  5. Go to "View/Download" and download the key by clicking "Download".


  6. Store the file in a folder for permanent storage.

Connect Visual Studio Code on Windows

Open VSC and press F1. Go to "Remote-SSH: Open SSH Configuration File" and enter the following lines:
    Host yourdomain.com
    
HostName yourdomain.com
    User your_cpanel_user
    IdentityFile [full_path_to_key]
Make sure to replace everything in bold with the correct information. Lastly, press F1 again, but this time select "Remote-SSH: Connect to Host" and choose the site you just set up. Once connected, click on Explorer (Ctrl + Shift + E) and then select "Open Folder". From the list, choose "public_html" and you’re all set... You’re now connected!

Connect Visual Studio Code on Mac

  1. Right-click on your downloaded file and hold "Option" to select: "Copy as Pathname".
  2. Open your terminal and enter the following: 
    chmod 0700 [full_path_to_key]
  3. Open VS Code and click the symbol in the bottom-left corner that looks like "><".


  4. Select "Connect to Host" from the options at the top center, then select "/Users/User/.ssh/config".


  5. Enter the following text and save the changes.
    Host TestDevelopmentSite
    HostName DemoSite.com
    User cPanelUser
    IdentityFile "[full_path_to_key]"

  6. Repeat step 3, select "Connect to Host..." and choose the host you just created. You will be asked for the password you set in cPanel when creating the key.



Wait for the connection and you’re all set!

Last updated: 09 de septiembre de 2024

Estimated reading time: 8 minutes

Did this article help you?
Let's Do It!

Start TODAY for only $2.45/month

Includes a web builder, 30GB of cloud storage, +200 Apps, and professional email.

Sign Up Now