Search code examples
ruby-on-railserror-handlingforeman

How to get rid of Permission denied (publickey) error on running bundle exec foreman start?


Whenever I run bundle exec foreman start I am getting below error.

enter image description here

It was working fine till now, but it stopped working suddenly.

Procfile

web: bundle exec rails s -p 3000

redis: redis-server --port 6379

db: /usr/local/bin/mysqld --gdb

watch_re: npm run watch:js:re

watch_vue: npm run watch:js:vue

sidekiq: bundle exec sidekiq -q high -q default -q crawler_facebook -q crawler_twitter -q mckinley -q twitter_io -q twitter_reach_freq -q master_update -q twitter_check_notification -q tw_report_file_creator -q mojaco_tw_crawler -q mojaco_fb_crawler -q fb_report_file_creator -q cache_manager -q facebook_attribution

ssh_tunneling_for_elasticache: ssh -N -L 60660:sherpa-production.y6mej4.0001.apne1.cache.amazonaws.com:60660 [email protected] -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null"


Solution

  • Your public SSH-key is unknown to the AWS-server.

    ssh_tunneling_for_elasticache: ssh -N -L 60660:sherpa-production.y6mej4.0001.apne1.cache.amazonaws.com:60660 [email protected] -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null"
    

    This command tries to build up a tunneling connection to the AWS. Here's how to setup the server with your public key if you can access it via the command line:

    1. Generate your key if you haven't already (on your local device): ssh-keygen

    2. Paste the key to the servers authorized-keys file ~/.ssh/authorized_keys


    Considering you have no access to the AWS other than through the web console, do the following as described here:

    Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

    Select your instance. In the Description tab, verify the value of Key pair name.

    If you did not specify a key pair when you launched the instance, you can terminate the instance and launch a new instance, ensuring that you specify a key pair. If this is an instance that you have been using but you no longer have the .pem file for your key pair, you can replace the key pair with a new one. For more information, see Connecting to Your Linux Instance if You Lose Your Private Key.