0
votes

I have a running instance that was created without a keypair, as I understand is not possible to apply a keypair to a running instance, I need to ssh connect to the instance to get some logs, how can I do that?

Right click on the instance -> Connect, shows a message saying that the instance is not associated with a key pair and "you will need to log into this instance using a valid username and password combination".

Our app runs on Elastic Beanstalk, the user should be ec2-user, but what about the password? How can I retrieve that?

PS: re-launch the instance with a keypair is not an option....

Thanks!

2

2 Answers

4
votes

You can download the logs using tail logs or full logs option in the console

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.loggingS3.title.html

The above will get you the default set of log files from the instance. If you want to get your files from one of the non-default locations you will need to update your environment with the following ebextension. Create a file custom-logs.config in a folder named .ebextensions in your app root. In the contents of your file create a log configuration file that points to your custom location.

Example contents:

files:
  "/opt/elasticbeanstalk/tasks/systemtaillogs.d/my-cool-logs.conf" :
    mode: "000777"
    owner: root
    group: root
    content: |
      /my-framework/my-logs/my-cool-log.log

This file is in yaml format, so be careful with the indentation. After creating this file you can deploy this new app version to your environment. Then when you snapshot logs using the instructions above you will get your custom logs.

0
votes

If there's any way to access the command line on your instance then you could

edit

/etc/ssh/sshd_config

setting change the line to:

PasswordAuthentication yes

SSH User:Pass access defaults to no on launch.