Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I connect to a new Amazon Lightsail instance from my Mac?

I've created a new NodeJS instance on Amazon Lightsail, and wish to connect to it from my Mac's command line. Not sure how to include the required SSH key in the connection command when it says Permission denied (publickey).

like image 673
Rohit Falor Avatar asked Sep 04 '17 00:09

Rohit Falor


2 Answers

  1. Go to the "SSH Keys" tab under your Lightsail Account page
  2. Select the Default option under your region and download the key pair file
    • Will be a .pem file, ex. LightsailDefaultPrivateKey-us-west-2.pem
  3. Open up your terminal and navigate to the directory where the above file is stored
  4. Run chmod 600 [fileName] at the command line to restrict file permission so only you can read it
  5. Run ssh -i [fileName] [username]@[Public IP] to establish the connection to Lightsail
    • Username and IP are available under the "Connect" tab on the Lightsail web dashboard for your resource
like image 60
Rohit Falor Avatar answered Nov 01 '22 13:11

Rohit Falor


To use your existing ~/.ssh/id_rsa.pub

  • Login to the server using the browser client
  • Do nano ~/.ssh/authorized_keys
  • Get your local public key with xclip -sel clip < ~/.ssh/id_rsa.pub
  • Append the ~/.ssh/authorized_keys with the copied key
  • Restart the instance
  • Login locally using ssh ubuntu@[instance_public_ip]
like image 27
Aleem Isiaka Avatar answered Nov 01 '22 13:11

Aleem Isiaka