AWS Lightsail Instance in CLI


I am deploying my first LAMP web app on amazon lightsail using the CLI. I am using windows powershell to interact with CLI. I am attempting to setup an SSH key before creating my instance as the exercise recommends. When I do here is what happens. I can't seem to get past this. Any advice would be appreciated...

aws lightsail create-key-pair \

--key-pair-name LightsailGuide > ssh_key_response.json

cat ssh_key_response.json | jq -r '.publicKeyBase64' > cat ssh_key_response.json | jq -r '.privateKeyBase64' > lightsailguide chmod 400 lightsailguide ********At line:2 char:7

  • --key-pair-name LightsailGuide > ssh_key_response.json
  •   ~

Missing expression after unary operator '--'. At line:2 char:7

  • --key-pair-name LightsailGuide > ssh_key_response.json
  •   ~~~~~~~~~~~~~

Unexpected token 'key-pair-name' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingExpressionAfterOperator********

asked 7 months ago65 views
1 Answer

Hi , I understand you are trying to setup an SSH key before creating an instance and you are getting an error.Please correct me if I misunderstood.

I replicated this on my end following AWS documentation, using the following command:

aws lightsail create-key-pair \
    --key-pair-name MyPersonalKeyPair

and I got a similar error. However, when I removed the backslash and make the one line command. I was able to create a new key-pair. This is how I did it:

  1. Installed and configured AWS CLI.
  2. I then created my SSH key with the following command on my powershell
aws lightsail create-key-pair --key-pair-name MyPersonalKeyPair > Karabo.json

You can verify that your key was created by going to the Lightsail console then click accounts. Go to SSH keys, your newly created key-pair will be on the list.

I hope this will be helpful!

answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions