newsapps / beeswithmachineguns

A utility for arming (creating) many bees (micro EC2 instances) to attack (load test) targets (web applications).
http://apps.chicagotribune.com/
MIT License
6.43k stars 631 forks source link

Issue withe `bees up` as per the README.md #204

Closed davidjeddy closed 1 year ago

davidjeddy commented 6 years ago

Following the README instructions to get a hive setup results in less than desired state.

(beesenv) user@machine:~/.../beeswithmachineguns$ tail ./.boto 
[Credentials]
aws_access_key_id = <REMOVED>
aws_secret_access_key = <REMOVED>

[Boto]
ec2_region_name = us-east-1a
ec2_region_endpoint = ec2.us-east-1.amazonaws.com  
(beesenv) user@machine:~/.../beeswithmachineguns$ bees up -s 4 -g ssh -k <REMOVED>
Connecting to the hive.
GroupId found: public
Placement: us-east-1d
Attempting to call up 4 bees.
('Unable to call bees:', u'Value () for parameter groupId is invalid. The value cannot be empty')
Is your sec group available in this region?
None
public
(beesenv) user@machine:~/.../beeswithmachineguns$

Added AWS 'ssh' security group with access via SSH from my IP as well. any idea what BWMG is needing at this point?

ghost commented 6 years ago

In your command, your group is called 'ssh', but the there is no security group "ssh" in that region for you.

~/.../beeswithmachineguns$ bees up -s 4 -g ssh -k

Make sure that group exist in that region, also try using a name for the security group that makes sense. IE "commerce-bees"

I used "commerce-bees"

davidjeddy commented 6 years ago

I created a Security group called 'ssh' and added port 22 from my IP. I also added port 22 to the default security group; same error. I'll give "commerce-bees" a try tonight.

ghost commented 6 years ago

Hmm ok so quick run down.

Create commerce-bees security group. Add your IP to port 22 to commerce-bees sec group. run the following

~/.../beeswithmachineguns$ bees up -s 4 -g commerce-bees

I ran had an issue that my regions AMI didn't exist anymore so I had to create a new one. Which was pretty simple plain ubuntu and install apache bench

davidjeddy commented 6 years ago

Added sec-group as directed: image

Attempted to bee's is up: image

If it helps: image

I'm missing something oblivious here, right?

ghost commented 6 years ago

Are you in the US East (N. Virginia) on the AWS console? For testing, you can allow ssh from any host since these are just temp machines and have no prod data on them.

The error message indicates an issue with not being able to find the security group in the US East (N. Virginia) region. So maybe your default region is something else look in the top right corner and see what it says.

davidjeddy commented 6 years ago

MY default region afaik is us-east-1; I'll try opening the commerce-bees sec group to the world and get back to you. Thank you for your help, it is appreciated.

ghost commented 6 years ago

No problem, I just noticed something in your message, are you using D subnet for us-east-1?

davidjeddy commented 6 years ago

'nother go around. I know the image does not show it but I double checked the SecGroup allowed SSH from the world.

It looks like the agent is able to connect

qwer

Tried this from another ticket as well: bwmg-2

ghost commented 6 years ago

I think I have the answer for you :) I just did.a little test using the AMI that is proving it gives me the same sec group not found bs. So i would recommend spinning up an ubuntu 14.04 or 16.04 instance and installing apache benchmark.

apt-get install apache2-utils

That is what bees uses, this is what i did in to make mine work since there was no ami for my region. Here is the command that works for me bringing them up, using my own ami.

bees up -s 2 -k sao_paulo -g commerce-bees -l ubuntu -z sa-east-1a -i ami-ff5e1293

ghost commented 6 years ago

screen shot 2018-02-04 at 11 42 48 am

davidjeddy commented 6 years ago

No joy :(. Even double checked and used an Ubuntu AMI from the us-east-1 region.

bwmg-204-5

ghost commented 6 years ago

I'll try to use that AMI, for Sao Paulo you tried using my AMI.

Only thing I can think of is removing bees and installing it a different method.

davidjeddy commented 6 years ago

Gave it another go:

  1. Removed the repo
  2. updated PIP
  3. installed via PIP

bwmg Sadly no dice.

ghost commented 6 years ago

What version of python are you running?

davidjeddy commented 6 years ago

Sorry for the late reply. Python is at version 2.7.12 on Ubuntu 16.04.

If it helps here is the command history:

 2001  cd ~/Projects
 2002  git clone https://github.com/newsapps/beeswithmachineguns.git
 2003  cd bwe
 2004  cd beeswithmachineguns/
 2005  python -v
 2006  python --version
 2007  pip install https://github.com/newsapps/beeswithmachineguns/archive/master.zip
 2008  sudo apt install python-pip
 2009  pip install https://github.com/newsapps/beeswithmachineguns/archive/master.zip
 2010  pip install --upgrade pip
 2011  vim ~/.boto
 2012  chmod 600 ~/.boto
 2013  bees up -s 4 -g public -k frakkingtoasters
 2014  bees up -s 4 -g ssh -k <REMOVED>
 2015  vim ~/.boto
 2016  bees up -s 4 -g ssh -k <REMOVED>
 2017  history

and the ~/.boto file:

[Credentials]
aws_access_key_id = <REMOVED>
aws_secret_access_key = <REMOVED>
ec2_region_name = us-east-1a
ec2_region_endpoint = ec2.us-east-1.amazonaws.com

Hope this helps.

ghost commented 6 years ago

No problem, ill follow your commands later this week and see if i can replicate your issue.

signitysolutions commented 6 years ago

Any update on this issue?

davidjeddy commented 6 years ago

Sorry, totally spaced out on this. I'll try it again this evening.

davidjeddy commented 6 years ago

So this is what I finally got to work:

Deleted the entire bees repo

Pre req:

  1. Ubuntu 16.04 box with python 2.7 and pip, newly installed
  2. Created ~/.boto and saved AWS credentials into it.

Process:

  1. Installed bees via pip
  2. Create a new ssh key in AWS, downloaded and saved to ~/.ssh/beestest.pem (set to perm to match the id_rsa key 0500 I believe)
  3. Created on
  4. Executed bees up -g default -z us-east-1a -s 2 -k beestest; response is
    
    pheagey@Armor-VIII:~$ bees up -g default -z us-east-1a -s 2 -k beestest
    New bees will use the "default" EC2 security group. Please note that port 22 (SSH) is not normally open on this group. You will need to use to the EC2 tools to open it before you will be able to attack.
    Read 2 bees from the roster: us-east-1a
    Connecting to the hive.
    GroupId found: default
    Placement: us-east-1a
    Attempting to call up 2 bees.
    Traceback (most recent call last):
    File "/home/pheagey/.local/bin/bees", line 6, in <module>
    main.main()
    File "/home/pheagey/.local/lib/python2.7/site-packages/beeswithmachineguns/main.py", line 277, in main
    parse_options()
    File "/home/pheagey/.local/lib/python2.7/site-packages/beeswithmachineguns/main.py", line 216, in parse_options
    bees.up(options.servers, options.group, options.zone, options.instance, options.type, options.login, options.key, options.subnet, options.tags, options.bid)
    File "/home/pheagey/.local/lib/python2.7/site-packages/beeswithmachineguns/bees.py", line 242, in up
    list(map(instance_ids.pop, [instance_ids.index(i) for i in dead_instances]))
    IndexError: pop index out of range

5. Checking the EC2 console we have progress, as in two new instances are started up...but where to from here?

I tried a couple time with different combinations of security groups, AZs, ssh keys, and instance count.
![image](https://user-images.githubusercontent.com/6232455/39794602-200f8bda-5319-11e8-85ca-67022a0a89a4.png)
danbadds38 commented 1 year ago
root@ba7d62120c6d:~/.ssh# bees up -s 2 -k bees -g bees-hq -l ubuntu -i ami-02354e95b39ca8dec -z us-east-1a
Connecting to the hive.
GroupId found: bees-hq
Placement: us-east-1a
Attempting to call up 2 bees.
Waiting for bees to load their machine guns...
Traceback (most recent call last):
  File "/usr/local/bin/bees", line 6, in <module>
    main.main()
  File "/usr/local/lib/python2.7/dist-packages/beeswithmachineguns/main.py", line 277, in main
    parse_options()
  File "/usr/local/lib/python2.7/dist-packages/beeswithmachineguns/main.py", line 216, in parse_options
    bees.up(options.servers, options.group, options.zone, options.instance, options.type, options.login, options.key, options.subnet, options.tags, options.bid)
  File "/usr/local/lib/python2.7/dist-packages/beeswithmachineguns/bees.py", line 249, in up
    instance.update()
  File "/usr/local/lib/python2.7/dist-packages/boto/ec2/instance.py", line 413, in update
    rs = self.connection.get_all_reservations([self.id], dry_run=dry_run)
  File "/usr/local/lib/python2.7/dist-packages/boto/ec2/connection.py", line 681, in get_all_reservations
    [('item', Reservation)], verb='POST')
  File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 1186, in get_list
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidInstanceID.NotFound</Code><Message>The instance ID 'i-03b05e9779a78ac90' does not exist</Message></Error></Errors><RequestID>b3d81a8f-83a5-4254-bb14-37066ee4a484</RequestID></Response>

getting an instance ID issue when providing an AMI? not sure but it doesn't make much sense?

davidjeddy commented 1 year ago

Issue is > 4 years old. Closing