How do I connect to my Amazon Lightsail instance?
- 07/15/2020 12:54 PM
Connecting to your Amazon Lightsail instance depends on whether you ordered a Linux or Windows server. Follow the guide below for instructions on how to connect.
How to connect to Linux instanceSelect your Amazon Lightsail instance from the My Services page in My NodeSpace.
Select Connection Details.
In the connection details box, take note of the following: (2) IP Address that you will be connecting to, (3) the username that you will use to connect, (4) the private key, and (5) the certificate key. Please follow the detailed instructions for the computer you are currently using.
macOS / LinuxCopy the SSH Private Key (4) and open a new text editor document and paste it in. We use Sublime Text, but you can use a text editor of your choice. Do not use Microsoft Word, LibreOffice Writer, or OpenOffice Writer. It should look something like this:
Paste your private key into the text editor and save it to either your Documents directory or, ideally, ~/.ssh/ directory. Give the key a filename that you can remember. Save the file without an extension. In this example, we're saving the key as "nodespacelightsail".
Now, go back to My NodeSpace and the connection details. Copy (5) SSH Cert Key and paste it into a new text editor file. It should look something like this:
Now save it to the same directory to where you saved your SSH Private Key. Name this file the exact same thing you called your private key, but with a .pub extension. If you do not save it to the same location or with the same file name, you will not be able to connect!
For example, I saved my private key in my Documents directory called "nsls-test". I'll save my public key as "nsls-test.pub" and also place it in my Documents directory.
Secure your private keyBefore we can connect, we need to secure our private key.
Using your file manager (GUI)If you're using your file manager, go to where you saved your private key file. Alternate click on it and select properties (or for macOS, Get Info). Find the file permissions. Remove all access to the file other than for your user account. For macOS users, click the padlock at the bottom and authenticate. Select any other user or group and press the "-" button. If you cannot remove a group, select the privilege and choose "No Access". For your user (identified by "(Me)"), make sure Read & Write is selected. It should look like the following. Click the padlock again to prevent changes from being made.
Using your Terminal (Command Line)If you prefer, you can use your Terminal. Open up your Terminal application (applies to both Mac and Linux), and navigate to where your private key is. For example, when I open my terminal, I am already in my home directory so I just have to type the command cd Documents/ and press return and I'm in my Documents directory.
Then issue the following command, replacing "PRIVATEKEY" with the file name of your private key that you specified when you saved it.
chmod 600 PRIVATEKEYFor example, I saved my private key as "nsls-test" so I'd type in chmod 600 nsls-test and press return.