

# Connect to Linux or Unix instances on Lightsail
Connect to Linux instances

Amazon Lightsail provides you with a browser-based SSH client, which is the fastest way to connect to your Linux or Unix instance. You can also use your own SSH client to connect to your instance. For more information, see [Download and set up PuTTY](lightsail-how-to-set-up-putty-to-connect-using-ssh.md).

Connect to your instance with SSH to perform administrative tasks on the server, such as installing software packages or configuring web applications. The browser-based SSH client requires no software installation, and is available almost immediately after you create an instance.

To connect to a Windows Server instance in Lightsail, see [Connect to your Windows-based instance](connect-to-your-windows-based-instance-using-amazon-lightsail.md).

**To connect to your Linux or Unix instance**

1. Sign in to the [Lightsail console](https://lightsail.aws.amazon.com/).

1. Access the browser-based SSH client for the instance that you want to connect to by using any of the following:
   + Choose the quick connect icon, as shown in the following example.  
![\[Open the browser-based SSH client with quick connect.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-quick-connect-to-your-instance-button.png)
   + Choose the actions menu icon (⋮), then choose **Connect**.  
![\[Open the browser-based SSH client with the actions menu.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-linux-2023-instance-home-connect.png)
   + Choose the name of the instance, and on the **Connect** tab, choose **Connect using SSH**.  
![\[Open the browser-based SSH client through the Connect tab.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-connect-using-ssh-button.png)

   You can start interacting with your instance when the browser-based SSH client opens, and a terminal screen is displayed as shown in the following example:  
![\[Browser-based SSH client in Lightsail.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-web-based-ssh-terminal.png)
**Note**  
The **Connect** tab also provides the information required to connect using your own SSH client. For more information, see [Download and set up PuTTY](lightsail-how-to-set-up-putty-to-connect-using-ssh.md)

## Interact with your Linux or Unix instance using the browser-based SSH client


Type Linux or Unix commands directly into the terminal screen, paste text into the terminal screen, or copy text from the terminal screen of the browser-based SSH client. The following sections show you how to copy and paste text to and from the clipboard in SSH.

**To paste text into the browser-based SSH client**

1. Highlight text in your local desktop, then press **Ctrl\$1C** or **Cmd\$1C** to copy it to your local clipboard.

1. In the bottom right corner of the browser-based SSH client, choose the clipboard icon. The browser-based SSH client clipboard text box appears.

1. Click into the text box, then press **Ctrl\$1V** or **Cmd\$1V** to paste the contents from your local clipboard into the browser-based SSH client clipboard.

1. Right-click any area on the SSH terminal screen to paste the text from the browser-based SSH client clipboard to the terminal screen.  
![\[Paste text into the browser-based SSH client in Lightsail.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/animated-gif-lightsail-paste-into-browser-terminal.gif)

**To copy text from the browser-based SSH client**

1. Highlight text on the terminal screen.

1. In the bottom right corner of the browser-based SSH client, choose the clipboard icon. The browser-based SSH client clipboard text box appears.

1. Highlight the text that you want to copy, then press **Ctrl\$1C** or **Cmd\$1C** to copy the text to your local clipboard. You can now paste the copied text anywhere in your local desktop.  
![\[Copy text from the browser-based SSH client in Lightsail.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/animated-gif-lightsail-copy-from-browser-terminal.gif)

# Connect to Lightsail Linux or Unix instances with the SSH command
Connect with SSH command

If your local machine uses a Linux or Unix operating system, including macOS, then you can connect to your Linux or Unix instance in Amazon Lightsail using the SSH client through a terminal window.

The method to connect to your instance described in this guide is one of many. For more information about the other methods, see [SSH key pairs](understanding-ssh-in-amazon-lightsail.md).

The easiest way to connect to your Linux or Unix instance in Lightsail is by using the browser-based SSH client that is available in the Lightsail console. For more information, see [Connect to your Linux or Unix instance](lightsail-how-to-connect-to-your-instance-virtual-private-server.md).

**Topics**
+ [

## Step 1: Confirm your instance is running and get the public IP address
](#terminal-ssh-get-public-ip-address)
+ [

## Step 2: Confirm the SSH key pair being used by your instance
](#terminal-ssh-confirm-key-pair)
+ [

## Step 3: Change the permissions of your private key and connect to your instance using SSH
](#terminal-ssh-change-key-file-permissions)

## Step 1: Confirm your instance is running and get the public IP address


In the following procedure, you sign in to the Lightsail console to confirm your instance is in the running state and to get the public IP address of your instance. Your instance must be in a running state in order to establish an SSH connection, and you will need the public IP address of your instance to connect to it later in this guide.

1. Sign in to the [Lightsail console](https://lightsail.aws.amazon.com/).

1. In the **Instances** section of the Lightsail home page, locate the instance that you want to connect to.

1. Confirm that the instance is in a running state, and make note of the public IP address of your instance.

   The state of your instance and its public IP address are listed next the name of your instance as shown in the following example.  
![\[The status and public IP address of an instance\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-status-and-public-ip-address.png)

## Step 2: Confirm the SSH key pair being used by your instance


In the following procedure you confirm the SSH key pair that is being used by your instance. You will need the private key of the key pair to authenticate to your instance and establish an SSH connection.

1. In the **Instances** section of the Lightsail home page, choose the name of the instance that you want to connect to.

   The **Instance management** page appears, with various tab options to manage your instance.  
![\[Instance management page in the Lightsail console\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-instance-management-page.png)

1. In the **Connect** tab, scroll down to see the key pair that is being used by your instance. There are two possibilities:

   1. The following example shows an instance that uses the default key pair for the AWS Region in which you created your instance. If your instance is using the default key pair, then you can continue to step 3 of this procedure to download the private key of the key pair. Lightsail stores the private key only for the default key pair of each AWS Region.  
![\[Default key pair used for a Lightsail instance\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-default-key-pair.png)

   1. The following example shows an instance that uses a custom key pair that you either uploaded or created. If your instance is using a custom key pair, then you need to locate the private key of the custom key pair where you store your keys. If you lost the private key of the custom key pair, then you will not be able to establish an SSH connection to your instance using your own client. However, you can continue to use the browser-based SSH client available in the Lightsail console. Continue to the next [Step 3: Change the permissions of your private key and connect to your instance using SSH](#terminal-ssh-change-key-file-permissions) section of this guide after you locate the private key of the custom key pair.  
![\[Custom key pair used for a Lightsail instance\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-custom-key-pair.png)

1. On the Lightsail home page, choose your user or role on the top navigation menu.

1. Choose **Account** in the dropdown menu.  
![\[Lightsail account tab\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-console-account-menu.png)

   The **Account management** page appears, with various tab options to manage your account settings.  
![\[Account management page in the Lightsail console\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-account-management-page.png)

1. Choose the **SSH keys** tab.

1. Scroll down, and choose the download icon next to the default key of the AWS Region of the instance that you want to connect to.  
![\[Download private key of default key pair from the Lightsail console\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-public-key-download.png)

   The private key is downloaded to your local machine. You might want to move the downloaded key to a directory in which you store all of your SSH keys, such as a "Keys" folder in your user's home directory. You will need to refer to the directory where the private key is saved in the next section of this guide. If the private key attempts to save as a format other than `.pem`, you should manually change the format to `.pem` before saving. 
**Note**  
Lightsail does not provide utilities for manipulating `.pem` files or other certificate formats. If you need to convert the format of your private key file, free and open-source tools such as [OpenSSL](https://www.openssl.org/docs/) are readily available.

   Continue to the next [Step 3: Change the permissions of your private key and connect to your instance using SSH](#terminal-ssh-change-key-file-permissions) section of this guide to use the private key you just downloaded and establish an SSH connection to your instance.

## Step 3: Change the permissions of your private key and connect to your instance using SSH


In the following procedure you will change the permissions of your private key file to be readable and writable only by you. You then open a terminal window in your local machine, and run the SSH command to establish a connection with your instance in Lightsail.

1. Open a terminal window on your local machine.

1. Enter the following command to make the private key of the key pair readable and writable only by you. This is a security best practice required by some operating systems.

   ```
   sudo chmod 400 /path/to/private-key.pem
   ```

   In the command, replace `/path/to/private-key.pem` with the directory path to where you saved the private key of the key pair that is being used by your instance.

   **Example:**

   ```
   sudo chmod 400 /Users/user/Keys/LightsailDefaultKey-us-west-2.pem
   ```

1. Enter the following command to connect to your instance in Lightsail using SSH:

   ```
   ssh -i /path/to/private-key.pem username@public-ip-address
   ```

   In the command, replace:
   + */path/to/private-key.pem* with the directory path to where you saved the private key of the key pair that is being used by your instance.
   + *username* with the username of your instance. You can specify one of the following user names depending on the blueprint that is used by your instance:
     + AlmaLinux OS 9, Amazon Linux 2, Amazon Linux 2023, CentOS Stream 9, FreeBSD, and openSUSE instances: `ec2-user`
     + Debian instances: `admin`
     + Ubuntu instances: `ubuntu`
     + Bitnami instances: `bitnami`
     + Plesk instances: `ubuntu`
     + cPanel & WHM instances: `centos`
   + Replace *public-ip-address* with the public IP address of your instance that you noted from the Lightsail console earlier in this guide.

   **Example with absolute path:**

   ```
   ssh -i /Users/user/Keys/LightsailDefaultKey-us-west-2.pem ec2-user@192.0.2.0
   ```

   **Example with relative path:**

   Notice the `./` prefixing the `.pem` file. Omitting `./` and simply writing `LightsailDefaultKey-us-west-2.pem` will not work.

   ```
   ssh -i ./LightsailDefaultKey-us-west-2.pem ec2-user@192.0.2.0
   ```

   You are successfully connected to your instance if you see the welcome message for your instance. The following example shows the welcome message for an Amazon Linux 2 instance; other instances blueprints have a similar welcome message. After you're connected, you can execute commands on your instance in Lightsail. To disconnect, enter `exit` and press Enter.  
![\[SSH connection established with a Lightsail instance\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-ssh-connection-established.png)

# Connect to Linux/Unix Lightsail instances with PuTTY
Connect with PuTTY

In addition to the browser-based SSH terminal in Lightsail, you can also connect to your Linux-based instance using an SSH client such as PuTTY. To learn how to set up PuTTY, see [Download and set up PuTTY to connect using SSH in Lightsail](lightsail-how-to-set-up-putty-to-connect-using-ssh.md).

**Note**  
To connect to a Windows-based instance using RDP, see [Connect to your Windows-based Lightsail instance](connect-to-your-windows-based-instance-using-amazon-lightsail.md).

You can use the default private key that Lightsail provides, a new private key from Lightsail, or another private key that you use with another service.

1. Start PuTTY (for example, from the **Start** menu, choose **All Programs**, **PuTTY**, **PuTTY**).

1. Choose **Load**, and then find your saved session.

   If you don't have a saved session, see [Step 4: Finish configuring PuTTY with your private key and instance information](lightsail-how-to-set-up-putty-to-connect-using-ssh.md).

1. Log in using one of the following default user names depending on your instance operating system:
   + AlmaLinux, Amazon Linux 2, Amazon Linux 2023, CentOS Stream 9, FreeBSD, and openSUSE instances: `ec2-user`
   + Debian instances: `admin`
   + Ubuntu instances: `ubuntu`
   + Bitnami instances: `bitnami`
   + Plesk instances: `ubuntu`
   + cPanel & WHM instances: `centos`

   For more information about instance operating systems, see [Choosing an image in Lightsail](compare-options-choose-lightsail-instance-image.md).

To learn more about SSH, see [SSH and connecting to your Amazon Lightsail instance](understanding-ssh-in-amazon-lightsail.md).

# Connect to your Lightsail Linux instance with PuTTY
Set up PuTTY

You can use an SSH client like PuTTY to connect to your Amazon Lightsail instance. PuTTY requires a copy of your private SSH key. You might already have a key, or you might want to use the key pair that Lightsail creates. Either way, we've got you covered. For more information about SSH, see [SSH key pairs](understanding-ssh-in-amazon-lightsail.md). This topic walks you through the steps to download a key pair and set up PuTTY to connect to your instance.

The method to connect to your instance described in this guide is one of many. For more information about the other methods, see [SSH key pairs](understanding-ssh-in-amazon-lightsail.md).

The easiest way to connect to your Linux or Unix instance in Lightsail is by using the browser-based SSH client that is available in the Lightsail console. For more information, see [Connecting to your Linux or Unix instance in Amazon Lightsail](lightsail-how-to-connect-to-your-instance-virtual-private-server.md).

## Prerequisites

+ You need a running instance in Lightsail. For more information, see [Create an instance in Amazon Lightsail](getting-started-with-amazon-lightsail.md).
+ We recommended that you create a static IP address and attach it to your instance so you won't have to reconfigure PuTTY if your public IP address changes later. For more information, see [Create a static IP and attach it to an instance](lightsail-create-static-ip.md).

## Step 1: Download and install PuTTY


PuTTY is a free implementation of SSH for Windows. Learn more about PuTTY on the [PuTTY website](http://www.chiark.greenend.org.uk/~sgtatham/putty/), including restrictions related to countries where encryption isn't allowed. If you already have PuTTY, you can skip to **Step 2**.

1. Download the PuTTY installer or executable file from the following link: [Download PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html).

   If you need help deciding which download to choose, see the [PuTTY documentation](http://www.chiark.greenend.org.uk/~sgtatham/putty/docs.html). We recommend using the latest version.

1.  Go on to **Step 2** to get your private key before you configure PuTTY. 

## Step 2: Get your private key ready


You have several options for getting your private key. You might want to use the default private key that Lightsail generates, you might want to have Lightsail create a new private key for you, or you might already have one from another service. The steps for each of these options is outlined in the following procedures:

1. Sign in to the [Lightsail console](https://lightsail.aws.amazon.com/).

1. On the Lightsail home page, choose your user or role on the top navigation menu.

1. Choose **Account** in the dropdown menu.  
![\[Lightsail account tab\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-console-account-menu.png)

1. Choose the **SSH Keys** tab.

1. Choose one of the following options depending on which private key you prefer to use:
   + **To use the default private key that Lightsail generates**, in the **Default keys** section of the page, choose the download icon next to the default private key for the AWS Region where your instance is located.  
![\[SSH key pairs in the Lightsail console\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/managing-key-pairs-download-default-key.png)
   + **To create a new key pair in Lightsail**, in the **Custom keys** section of the page, choose **Create key pair**. Choose the AWS Region where your instance is located, and choose **Create**. Enter a name, and choose **Generate key pair**. You will be given the option to download the private key.
**Important**  
You can only download the private key once. Save it in a secured location.
   + **To use your own key pair**, choose **Upload New**. Choose the AWS Region where your instance is located, and choose **Upload**. Choose **Upload file**, and then locate the file in your local drive. Choose **Upload key** when you're ready to upload your public key file to Lightsail.

1. If you downloaded the private key, or you created a new private key in Lightsail, then make sure to save the `.pem` key file somewhere you can easily find it.

   We also recommend that you set permissions for the file so that no one else can read it.

## Step 3: Configure PuTTYgen with your Lightsail private key


Now that you have a copy of your `.pem` key file, you can set up PuTTY using the PuTTY Key Generator (PuTTYgen).

1. Start PuTTYgen (for example, from the **Start** menu, choose **All Programs**, **PuTTY**, **PuTTYgen**).

1. Choose **Load**.

   By default, PuTTYgen displays only files with the `.ppk` extension. To locate your `.pem` file, select the option to display files of all types.

1. Choose `lightsailDefaultKey.pem`, and then press **Open**.

   PuTTYgen confirms that you successfully imported the key, and then you can choose **OK**.

1. Choose **Save private key**, and then confirm you don't want to save it with a passphrase.

   If you choose to create a passphrase as an extra measure of security, remember you will need to enter it every time you connect to your instance using PuTTY.

1. Specify a name and a location to save your private key, and then choose **Save**.

1. Close PuTTYgen.

## Step 4: Finish configuring PuTTY with your private key and instance information


You're almost there\$1 Hang on while we make one last change.

1. Open PuTTY.

1. From Lightsail, grab the public IP address (hopefully you're using a [static IP address](understanding-static-ip-addresses-in-amazon-lightsail.md)) from the instance management page.

   You can get the public IP address from the Lightsail home page, or choose your instance to view more details about it.

1. Type (or paste) the public IP address into the **Host Name (or IP address)** field.
**Note**  
Port 22 is already open for SSH on your Lightsail instance, so accept the default port.

1. Under **Connection**, expand **SSH** and **Auth**, and then choose **Credentials**.  
![\[PuTTY and the SSH Auth-Credentials option in the configuration dialog\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/putty-configuration-connection-ssh-auth.png)

1. Choose **Browse** to navigate to the `.ppk` file that you created in the previous step, and then choose **Open**.

1. Choose **Open** again, and then choose **Accept** to trust this connection in the future.

1. Log in using one of the following default user names depending on your instance operating system:
   + AlmaLinux, Amazon Linux 2, Amazon Linux 2023, CentOS Stream 9, FreeBSD, and openSUSE instances: `ec2-user`
   + Debian instances: `admin`
   + Ubuntu instances: `ubuntu`
   + Bitnami instances: `bitnami`
   + Plesk instances: `ubuntu`
   + cPanel & WHM instances: `centos`

   For more information about instance operating systems, see [Choose an image](compare-options-choose-lightsail-instance-image.md).

1. Be sure to save your connection for future use.

## Next steps


If you need to connect again, see [Connect to your Linux/Unix-based instance with PuTTY](lightsail-how-to-ssh-connect-to-instance-virtual-private-server-using-putty.md).

# Transfer files securely to Lightsail Linux instances with SFTP
Transfer files with SFTP

You can transfer files between your local computer and your Linux or Unix instance in Amazon Lightsail by connecting to your instance using SFTP (SSH File Transfer Protocol). To do this, you must get the private key for your instance, and then use it to configure the FTP client. This tutorial shows you how to configure the FileZilla FTP client to connect to your instance. These steps may also apply to other FTP clients.

**Topics**
+ [

## Prerequisites
](#connecting-to-linux-unix-instance-using-sftp-prerequisites)
+ [

## Get the SSH key for your instance
](#get-the-ssh-key-for-your-instance)
+ [

## Configure FileZilla and connect to your instance
](#configure-filezilla-and-connect-to-your-instance)

## Prerequisites


Complete the following prerequisites if you haven't already:
+ Download and install FileZilla on your local computer. For more information, see the following download options:
  + [Download FileZilla Client for Windows](https://filezilla-project.org/download.php?platform=win64)
  + [Download FileZilla Client for Mac OS X](https://filezilla-project.org/download.php?platform=osx)
  + [Download FileZilla Client for Linux](https://filezilla-project.org/download.php?platform=linux)
+ Get the public IP address of your instance. Sign in to the [Lightsail console](https://lightsail.aws.amazon.com/), and then copy the public IP address that is displayed next to your instance, as shown in the following example:  
![\[The public IP for an instance in Lightsail.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-instance-public-ip.png)

## Get the SSH key for your instance


Complete the following steps to get the default private key for the AWS Region of your instance, which is required to connect to your instance using FileZilla.

**Note**  
If you’re using your own key pair, or you created a key pair using the Lightsail console, locate your own private key and use it to connect to your instance. Lightsail does not store your private key when you upload your own key or create a key pair using the Lightsail console. You cannot connect to your instance using SFTP without your private key.

1. Sign in to the [Lightsail console](https://lightsail.aws.amazon.com/).

1. On the Lightsail home page, choose your user or role on the top navigation menu.

1. Choose **Account** in the drop-down menu.  
![\[Account menu in the Lightsail console.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-console-account-menu.png)

1. Choose the **SSH Keys** tab.

1. Scroll down to the **Default keys** section of the page.

1. Choose **Download** next to the default private key for the region where your instance is located.  
![\[SSH keypairs in the Lightsail console.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/managing-key-pairs-download-default-key.png)

1. Save your private key in a secured location on your local drive.

## Configure FileZilla and connect to your instance


Complete the following steps to configure FileZilla to connect to your instance.

1. Open FileZilla.

1. Choose **File**, **Site Manager**.

1. Choose **New site**, then give your site a name.  
![\[New site configuration in FileZilla.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-filezilla-sftp-new-site.png)

1. In the **Protocol** dropdown, choose **SFTP – SSH File Transfer Protocol**.

1. In the **Host** text box, enter or paste your instance’s public IP address.

1. In the **Logon Type** dropdown, choose **Key File**.

1. In the **User** text box, enter one of the following default user names depending on your instance operating system:
   + AlmaLinux, Amazon Linux 2, Amazon Linux 2023, CentOS Stream 9, FreeBSD, and openSUSE instances: `ec2-user`
   + Debian instances: `admin`
   + Ubuntu instances: `ubuntu`
   + Bitnami instances: `bitnami`
   + Plesk instances: `ubuntu`
   + cPanel & WHM instances: `centos`
**Important**  
If you are using a different user name than the default user names listed here, then you might need to give the user write permissions to your instance.

1. Next to the **Key File** text box, choose **Browse**.  
![\[SFTP configuration in FileZilla.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-filezilla-sftp-configuration.png)

1. Locate the private key file that you downloaded from the Lightsail console earlier in this procedure, and then choose **Open**.
**Note**  
If you are using Windows, change the default file type to **All files** when searching for your pem file.  
![\[File extension setting in FileZilla open dialog\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-filezilla-file-extention-setting.png)

1. Choose **Connect**.

1. You may see a prompt similar to the following example, indicating that the host key is unknown. Choose **OK** to acknowledge the prompt and connect to your instance.  
![\[Unknown host key in FileZilla.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-filezilla-unknown-hostkey.png)

   You are successfully connected if you see status messages similar to the following example:  
![\[FileZilla successfully connected to an instance in Lightsail.\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-filezilla-sftp-successfully-connected.png)

   For more information about using FileZilla, including how to transfer files between your local computer and your instance, see the [FileZilla Wiki page](https://wiki.filezilla-project.org/Using).