forem / selfhost

Selfhost your Forem Community on your own infrastructure 🎉
https://www.forem.com/get-started/
GNU Affero General Public License v3.0
1.44k stars 172 forks source link

SSH task hangs then fails #17

Closed 0bserver07 closed 3 years ago

0bserver07 commented 3 years ago

At first, I checked the EC2 / security group, it is good to go, 22 is open to local IP.

Here is the error log:

TASK [Wait 300 seconds for port 22 to become open] ********************************************************************

fatal: [forem]: FAILED! => changed=false
  elapsed: 300
  invocation:
    module_args:
      active_connection_states:
      - ESTABLISHED
      - FIN_WAIT1
      - FIN_WAIT2
      - SYN_RECV
      - SYN_SENT
      - TIME_WAIT
      connect_timeout: 5
      delay: 20
      exclude_hosts: null
      host: XX.XX.XX.XX
      msg: null
      path: null
      port: 22
      search_regex: null
      sleep: 1
      state: started
      timeout: 300
  msg: Timeout when waiting for  XX.XX.XX.XX

PLAY RECAP ************************************************************************************************************
forem                      : ok=41   changed=17   unreachable=0    failed=1    skipped=1    rescued=0    ignored=0

I'm not sure what's the error here.

jdoss commented 3 years ago

Can you manually SSH into the server? https://github.com/forem/selfhost#ssh-examples

If this fails then it sounds like the EC2 never launched correctly. If you can SSH into it, try rerunning the playbook.

0bserver07 commented 3 years ago

thanks for getting back to me @jdoss , I can't SSH into the machine manually, since I'm not certain where the ".pem" file go while deploying the instance?

jdoss commented 3 years ago

See Step 7 of the Quickstart https://github.com/forem/selfhost#quick-start. If you followed this guide it is located ${HOME}/.ssh/forem.pub

0bserver07 commented 3 years ago

Thanks, I think the github link doesn't explain what needs to happen for this use-case:

Here is an outline of steps I'm taking:

cd ~/.ssh/
  1. Generate the key with $ ssh-keygen -t rsa -b 2048 -v
ssh-keygen -t rsa -b 2048 -v
  1. when asked to enter file in which to save the key, type forem, confirm by Enter.

  2. then wee will get two files generated, one will be forem and one will be forem.pub.

  3. Then rename the forem to forem.pem, so you will have two files, forem.pub and forem.pem


I terminate the server and redo every to avoid config overlaps as well.

cmgorton commented 3 years ago

Hey @0bserver07 if you are using AWS as your cloud provider you can try using this Forem AWS Setup guide. There is a section that goes in to more detail on how to ssh into your server.

If you have any more questions regarding getting set up or errors you are seeing please feel free to post on forem.dev with the #help and #selfhost tags. Someone on the team will be able to help you over there! Thanks 😄

maslof commented 3 years ago

How were you able to solve this problem?

maslof commented 3 years ago

I have same problem if I change region us-east-1 -> eu-west-1

cmgorton commented 3 years ago

I have same problem if I change region us-east-1 -> eu-west-1

Hey @MaslovAnton just to confirm are you having trouble with SSH (step 11 in the quick start) and the problem is occurring only when you change your region to us-east-1 -> eu-west-1?

maslof commented 3 years ago

I have problem in this if i change fcos_aws_region: us-east-1 -> eu-west-1. Error on task TASK [Wait 300 seconds for port 22 to become open]

And i can't connect by ssh and generated rsa key

In default region (us-east-1) it was OK.

0bserver07 commented 3 years ago

@MaslovAnton for now it worked when I switched to us-east-1, there might be something hard-coded, but to make it work you can just do that change.

I tried, -west-, but that's what led to the ssh error.

maslof commented 3 years ago

Thanks. Same error in -west- region

cmgorton commented 3 years ago

I am going to walk through setting up my Forem on AWS again today and I will change the region. I'll let you know what steps I take and if I get the same errors you all are seeing @0bserver07 and @MaslovAnton . If I do I'll ping our systems team to get more info on why the error is occurring.