Open chensteven opened 6 years ago
I have the same problem
Hi, as per the documents initialize command is for checking and updating scan.py. Use start command to start the cluster. Hope this will help you
I found the problem. The program is trying to run the command "ssh-copy-id {'address': 'pi@172.31.72.83', 'notes': '83', 'wlan': 'wlan1'}" but ssh-copy-id can't take {...} as an argument. I'm not sure what happened there but if you remove that part of the code, it will work.
let me try this
When execute the cluster.py start this same raspberry don't run the scan.py program but the others yes. That it's normal?
Best Regards
This is a mistake in the script https://github.com/schollz/find-lf/blob/f17ca7ed487fe64d0212f81164ab85a1c753fc46/tools/cluster.py#L375
elif command == "initialize":
print("copying ips")
for address in config['pis']:
c = 'ssh-copy-id %(address)s
r, code = run_command(c % {'address': address})
is feeding a JSON object to ssh-copy-id
which obviously doesn't work.
Instead it should only pass the address
field of the current config['pis']
object.
To fix it simply change the code like here and it should work again.
I get the same error. I also change the address to pi and another error occur, name address is not define. Please help.
Make sure that you changed both lines 377 and 379 in the original cluster.py correctly (as described here).
Otherwise I'm afraid your error is of a different nature as originally described in this thread.
Thank you for replying. Below is the changes that I have done
elif command == "initialize":
print("copying ips")
for pi in config['pis']:
c = 'ssh-copy-id %(address)s'
r, code = run_command(c % {'address':pi['address']})
if code == 1:
print("Could not connect to %s" % address)
return
logger.debug(r)
logger.debug(code)
Below is the error message I got when running the code
Traceback (most recent call last):
File "cluster.py", line 499, in
Ah, I forgot to change the print(...) argument to pi['address']
also.
See my latest commit
About your error though:
As I suspected your problem is not the same as the one described in this thread and even the latest change will not solve your problem (merely improves debugging). It seems your ssh-copy-id
call is not successful, I suggest running ssh-copy-id
with your RPi's [user@]hostname
in the command line to see what the issue is.
I think so too. Thanks for the tips.
This is a great project, that being said, there are a few quirks (not really quirks but just normal config things) that need a bit of explaining, if you get the could not connect error, read these tips...
Idea: The "master" connects to the "slaves" via ssh and executes a python script (scan.py), for this to work there needs to be a passwordless connection with ssh and in addition the user connecting needs to be able to sudo without a password.
Issue: Could not connect. For me this happened because I didn't have SSH setup right to allow logins without a password. Could not start also occurs when there is no scan.py file or no privileges.
You can circumvent the initialization script and just manually prepare each raspberry pi, I had to do this running "Kali Pi" because the premade scripts didn't work. In my case I was using a non-pi master and two pi zero w's as slaves.
Here is how I got it to work:
From the "master", run: sudo apt-get install openssh-client openssh-server nmap then, wget https://raw.githubusercontent.com/schollz/find-lf/master/tools/cluster.py and finally: ssh-keygen
This will now make an ssh key in /home/
On each slave pi run: visudo (as root or via sudo) edit the %sudo line and set to: %sudo ALL=(ALL:ALL) NOPASSWD: ALL
Note: This is insecure if these devices have potential remote access. You may consider adding your own group instead. In my case this was fine ....
From the master, login to each slave via: ssh
If the SSH connections work ok then login to each slave and get the scan.py script by running this command: wget https://raw.githubusercontent.com/schollz/find-lf/master/node/scan.py -O scan.py
Also get the pre-reqs, so run this on each slave pi: Run: apt-get update apt-get install -y htop vim python3 python3-requests apt-get install wireless-tools firmware-atheros usbutils wireshark tshark hostapd -y
From the master you can now run python3 cluster.py initialize Enter the IP of each pi and leave the others as default. Make a group name. Ignore any errors that may be thrown as we used a non standard workflow.
Run on master: python3.py cluster start
You should see each slave pi respond and either start the service or say it's already running!
Two more things to add, on my setup even though it responded well it did not actually get any scan results, I logged into the slave pi's and manually ran the wireshark command that scan.py runs to debug and saw the issue is permissions. I had to do the following on each slave pi:
sudo dpkg-reconfigure wireshark-common
When prompted to allow non-superusers select YES/ALLOW
then run: sudo chmod +x /usr/bin/dumpcap
Reboot the slave pis and restart the scan on the cluster.
When I try running python3 cluster.py initialize, I get "Could not connect to {'address': 'pi@..., 'notes': 'Test', 'wlan': 'wlan0'}"
Any way to debug this? Thank you.