Troubleshooting Kamal setup error for Go backend and PostgreSQL deployment

I’m having trouble setting up a Go backend and PostgreSQL database using Kamal 2. When I run the setup command, I get this error:

ERROR (KeyError): Exception while executing as ubuntu@localhost: key not found: #<SSHKit::Host:0x000059c7eb101ed8 @keys=[], @local=false, @use...

The container starts, but I can’t access it through the Kamal proxy. I’ve double-checked my deploy.yml file and made sure the SSH key is in the right place on the host.

I’ve tried adding the key with ssh-add, but no luck. Any ideas on what might be causing this? I’m pretty stumped and could use some help figuring out why Kamal can’t find the key.

Here’s a snippet of my deploy.yml for reference:

ssh:
  keys: [~/my-keypair.pem]
  user: ubuntu
  keys_only: true

env:
  clear:
    API_PORT: '8080'
    DB_PORT: '5432'
    DB_USER: 'postgres'
    DB_NAME: 'myapp_db'

Has anyone run into a similar issue or know how to troubleshoot this KeyError?

yo, I had this issue too. try checkin ur ~/.ssh/config file. sometimes kamal gets confused w/ different keys. also, make sure ur server’s sshd_config allows key auth. might wanna try ssh’ing manually first to see if it works. if all else fails, maybe regenerate the key? good luck!

I’ve encountered similar issues when deploying with Kamal. One thing that often gets overlooked is the host configuration in the deploy.yml file. Make sure you’ve properly specified the host details, including the correct IP address or domain name. Additionally, verify that the SSH user (ubuntu in your case) has the necessary permissions on the target server. Sometimes, it’s helpful to test the SSH connection manually first to isolate any potential network or authentication problems. If all else fails, you might want to consider regenerating your SSH key pair and updating it on both your local machine and the server. This can sometimes resolve mysterious key-related errors.

hmm, that error sounds familiar. have u tried checking ur ssh config file? sometimes the issue is with the ssh agent not the key itself. also, double-check if the key permissions are set correctly (600). maybe try running the command with verbose output (-v flag) to see more details? curious to hear if any of these help!