Install the Remote - SSH Plugin in VS Code
- Open Extensions in VS Code.
- Search for Remote - SSH and install it. This plugin will include a configuration tool that you will use to connect via SSH.
To log in, you will need:
- Username
- PEM File
This guide will also cover:
- How to find your Bitnami app password.
- The location of public files if you are using WordPress.
Finding Your Credentials
Username
Lightsail uses Bitnami containers. Make sure you have the correct username for your container.
For WordPress containers (at the time of writing), the default username is:
bitnami
The full SSH login will look like this:
ssh bitnami@<your-instance-IP>
PEM File (Key Pair)
- Log in to the Amazon Lightsail dashboard and go to your instance's SSH settings.
- Scroll down to find the public key section and download your PEM file.
- Save the PEM file to your
.sshfolder:- On macOS:
~/.ssh/tot.pem - On Windows:
C:\Users\<YourUsername>\.ssh\tot.pem
- On macOS:
- Update your SSH configuration file (
~/.ssh/configon macOS/Linux, orC:\Users\<YourUsername>\.ssh\configon Windows). Format the configuration file as follows:
Host MyTestSite HostName <your-instance-ip> User bitnami IdentityFile ~/.ssh/tot.pemExample:
Host MyTestSite HostName 11.234.567.23 User bitnami IdentityFile ~/.ssh/tot.pemBitnami Application Password
You may not need this password for SSH, but it could be required elsewhere.
To find it:
- Open the virtual terminal in your Lightsail instance.
- Run the following command:
cat bitnami_application_password - Copy and save the password temporarily.
Setting Up SSH in VS Code
Using the VS Code Interface
- Click on the Remote - SSH icon in the left toolbar.
- Under SSH Targets, click the + icon.
- Enter the SSH command in the following format:
ssh {username}@{ip-address}
Example: ssh bitnami@11.234.567.23
- Select the configuration file location (e.g.,
~/.ssh/config). - The new Lightsail host will appear under SSH Targets. Click the Open in New Window icon to connect.
Fixing PEM File Permission Errors
If you encounter a permissions error with your PEM file:
- Open a terminal and navigate to the PEM file's directory.
- Change its permissions:
chmod 400 <your-pemfile.pem>
Use 400 if you do not plan to change the file often.
Use 600 if you will update it more frequently.
Example:
chmod 400 tot.pemWordPress File Locations
If you are using WordPress and need to modify files, the public files are located at:
/home/bitnami/apps/wordpress/ /home/bitnami/apps/wordpress/htdocsReference Video
For a visual guide, watch this helpful tutorial starting at the 1-minute mark:
Now you are all set to connect to your Lightsail instance using Remote SSH in VS Code!