Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not connect to RPi #29

Open
chensteven opened this issue Jan 2, 2018 · 13 comments
Open

Could not connect to RPi #29

chensteven opened this issue Jan 2, 2018 · 13 comments

Comments

@chensteven
Copy link

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.

@arenasInnovared
Copy link

I have the same problem

@rpandey91
Copy link

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

@chensteven
Copy link
Author

I found the problem. The program is trying to run the command "ssh-copy-id {'address': '[email protected]', '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.

@arenasInnovared
Copy link

let me try this

@arenasInnovared
Copy link

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

@BS1A
Copy link

BS1A commented Jan 25, 2018

This is a mistake in the script

elif command == "initialize":

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.

BS1A added a commit to BS1A/find-lf that referenced this issue Jan 25, 2018
@arms203
Copy link

arms203 commented Apr 11, 2018

I get the same error. I also change the address to pi and another error occur, name address is not define. Please help.

@BS1A
Copy link

BS1A commented Apr 11, 2018

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.

@arms203
Copy link

arms203 commented Apr 11, 2018

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
main(args, config)
File "cluster.py", line 381, in main
print("Could not connect to %s" % address)
NameError: name 'address' is not defined

BS1A added a commit to BS1A/find-lf that referenced this issue Apr 12, 2018
@BS1A
Copy link

BS1A commented Apr 12, 2018

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.

@arms203
Copy link

arms203 commented Apr 13, 2018

I think so too. Thanks for the tips.

@503Dev
Copy link

503Dev commented Feb 2, 2019

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:

  1. 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

  2. This will now make an ssh key in /home//.ssh , it's id_rsa.pub, you need to copy this to each slave pi, to do so run: ssh-copy-id @
    Note: Make sure the username exists on the slave pi, if your master is not a pi then it probably does not share a common username. In that case just login to the slave pi's as root and the do: sudo adduser and replace with whatever use you use on the master, rerun the ssh-copy-id once the user is added.

  3. 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 ....

  1. From the master, login to each slave via: ssh
    Note: If this does not work your SSH key is not setup right, see above. Make sure the .ssh directory on slaves is set to chmod 700 and owned by the user not root.

  2. 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

  3. 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

  4. 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.

  5. 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!

@503Dev
Copy link

503Dev commented Feb 2, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants