If you’re running an Amazon Lightsail instance, the chances are that you’ll want to edit files directly on the server. To do that, you need to connect to your Lightsail instance using SFTP (SSH File Transfer Protocol), which is a more secure option than the traditional FTP (File Transfer Protocol). It allows server-to-server transfers between yourself and your Lightsail instance in a safe way, allowing you to upload, download or edit files hosted on your Lightsail server.

Choosing an SFTP Client

There’s many different clients available and most support SFTP. Two of our favourites are Coda (Mac OS) and Cyberduck (Mac OS and Windows).

Cyberduck is available for free, so it tends to be a popular option if all you’re looking for is an SFTP client. It supports other protocols and cloud storage systems as well, such as FTP, WebDAV, Amazon S3, OpenStack Swift, Backblaze B2, Microsoft Azure & OneDrive, Google Drive and DropBox.

Coda is a little more advanced and is primarily a text editor with support for numerous programming languages, but also includes support for protocols such as FTP, SFTP, WebDAV, Amazon S3.

If you’re looking for an excellent way to write code and be connected to your server environment at the same time, then Coda is a great choice, despite being paid software. If you’re just looking for an SFTP client, then Cyberduck is hard to beat.

Connecting to Lightsail using SFTP

We’re going to show you how to connect to Lightsail using both Coda and Cyberduck since they are both popular options, and we’re also going to be using the Terminal application in a Mac OS environment. The process is essentially the same for both, with just a few subtle differences between the Coda and Cyberduck interfaces.

Download the Lightsail private key

To connect to your server using SFTP, you’ll first need to obtain the private key .pem file for your Lightsail instance. It is used in the SFTP client instead of a password and is a way to protect your connections from stolen passwords.

  1. Go to the Lightsail Account Page
  2. Select the SSH keys tab
  3. Click Download to obtain the .pem file

Lightsail Manage your SSH keys
Elevate permissions on the Lightsail private key

For the private key to work correctly, we need to elevate the permissions on the key file.

  1. Start the Terminal application on Mac OS from Finder under Applications > Utilities > Terminal.
  2. Type chmod 400  (note the addition of space at the end of this command).
  3. Drag and drop the .pem file you downloaded in the previous section onto the Terminal window.
  4. Hit return to run the command against the .pem file.
  5. Type exit and hit return, then Cmd+Q to quit the Terminal application.

Terminal Lightsail Default Key permissions

Move the private key to your .ssh folder

The .ssh folder in Mac OS is a particular location for storing private keys. You don’t have to use this location, but most SFTP clients will automatically look here for a key when you first create a new connection. If you don’t wish to use the .ssh folder, you can add your private key .pem file from any location directly into the SFTP client. See more in the following section.

  1. From the Finder application, press Cmd+Shift+G on your keyboard.
  2. Enter ~/.ssh in the Go to folder field.
  3. Hit return or click Go.
  4. Drag your .pem file from its current location into the .ssh folder.

Finder SSH folderConnect to the Lightsail server using an SFTP client

Use Coda to connect to Lightsail

  1. Right-click a blank area of the Coda interface and select Add new site.
  2. Set the Nickname field to a friendly name, such as your website or domain name.
  3. (Optional) Set the Remote URL field to your website home page address. It displays an image of your website in the connection, making it easier to identify.
  4. Click the Server tab.
  5. Ensure the Protocol is SFTP.
  6. In Server enter the Public IP address of your Lightsail instance.
  7. In Username enter bitnami – this is the default username for Lightsail installations and can not be changed.
  8. In the Password field, click the image of the key.
  9. Find and select the .pem file you downloaded earlier. If you can’t see the .pem file, you may not be in the .ssh folder. If so, navigate to Macintosh HD > Users > [username] > .ssh and you should see your private key .pem file. If you’ve opted not to store your .pem file in the .ssh folder, you can select the file from any other location.
  10. Click Choose key file.
  11. Click Save.
  12. Double-click the new site added to the Coda interface.
  13. Your SFTP connection is now open, and you can edit files.

Coda SFTP connection

Use Cyberduck to connect to Lightsail

  1. On the toolbar, click Open Connection.
  2. Select SFTP (SSH File Transfer Protocol) from the dropdown box.
  3. In the Server field, enter the Public IP address of your Lightsail instance.
  4. In Username enter bitnami – this is the default username for Lightsail installations and can not be changed.
  5. From the SSH Private Key dropdown, select the .pem file you added to the .ssh folder earlier. If you’ve opted not to store your .pem file in the .ssh folder, select Choose then locate and select your .pem file and click the Choose button.
  6. Click the Connect button.
  7. Your SFTP connection is now open.
  8. To save this connection for future use, click Action on the toolbar, then New Bookmark.
  9. A new window will appear with the credentials you entered earlier.
  10. Set the Nickname field to a friendly name, such as your website or domain name.
  11. Close the window.
  12. Double-click the new connection added to the Cyberduck interface.
  13. Your SFTP connection is now open, and you can edit files.

Cyberduck SFTP connection