Kali Raspberry Pi/Headless SSH Problem
From charlesreid1
Now we come to a question: is SSH enabled by default on Kali Linux builds for the Raspberry Pi?
Some say yes, some say no. I say, sort of.
In my experience, the Kali Linux Raspberry Pi image will start an SSH service, and it will listen on port 22, but you have to wait a while, and give it multiple tries. If at first your connection is refused, wait a little while, and try again.
Ethernet and Power Source
You should note that there may be issues with spotty connectivity if you power the Raspberry Pi from a Mini USB cable. When connected to a Mini USB cable, the Raspberry Pi can't draw enough power, and the Ethernet can sometimes be turned off.
Kali Linux Raspberry Pi: SSH: Connection Refused: The Problem
This problem drove me nuts. I kept seeing an SSH error, "ssh: connect to host port 22: Connection refused" - even though the Raspberry Pi was up, online, and responding to ping.
$ ssh root@10.0.0.114 ssh: connect to host 10.0.0.114 port 22: Connection refused $ ping 10.0.0.114 PING 10.0.0.114 (10.0.0.114): 56 data bytes 64 bytes from 10.0.0.114: icmp_seq=0 ttl=64 time=6.927 ms 64 bytes from 10.0.0.114: icmp_seq=1 ttl=64 time=6.719 ms 64 bytes from 10.0.0.114: icmp_seq=2 ttl=64 time=1.378 ms 64 bytes from 10.0.0.114: icmp_seq=3 ttl=64 time=8.679 ms
It was independent of how I set up the Pi on the network. Whether it was connected directly to the router, or directly to my computer:
$ ssh root@169.254.113.200 ssh: connect to host 169.254.113.200 port 22: Connection refused $ ping 169.254.113.200 PING 169.254.113.200 (169.254.113.200): 56 data bytes 64 bytes from 169.254.113.200: icmp_seq=0 ttl=64 time=6.927 ms 64 bytes from 169.254.113.200: icmp_seq=1 ttl=64 time=6.719 ms 64 bytes from 169.254.113.200: icmp_seq=2 ttl=64 time=1.378 ms 64 bytes from 169.254.113.200: icmp_seq=3 ttl=64 time=8.679 ms
The headless Kali Raspberry Pi is there, and listening, but refusing our connections.
Failure after failure.
But then, once, it just magically worked, exactly like it was supposed to:
$ nmap -p1-1000 169.254.113.200 Starting Nmap 6.47 ( http://nmap.org ) at 2015-07-27 13:39 PDT Nmap scan report for 169.254.113.200 Host is up (0.039s latency). All 1000 scanned ports on 169.254.113.200 are closed Nmap done: 1 IP address (1 host up) scanned in 0.48 seconds
And then it failed again.
It was like the definition of insanity, doing the same thing over and over again and expecting different results, except every once and a while, I would get different results. Which obviously meant I was insane.
I thought this was a network issue, so I tried different network configurations. No dice.
I thought this was an issue with the SSH service, so I tried tinkering with rc2.d and init.d to verify the sshd service was in fact running at boot time on the headless Raspberry Pi and was listening.
I tried everything. I banged my head against the wall. Then I tried plugging the Raspberry Pi into the wall, instead of plugging it directly into my computer via mini USB cable.
All the SSH problems disappeared into the aether.
Kali Linux Raspberry Pi: SSH: Connection Refused: The Solution
The solution is that simple: you just plug your Raspberry Pi into the wall with the USB wall adapter. Don't connect it to your computer with a mini USB cable.
When you plug the Raspberry Pi in via the mini USB cable, it needs more juice than is available, so it starts shutting things off. That means the ethernet port stops listening, and your ability to connect gets really spotty. But it's still listening - so every once and a while, you can SSH into the Raspberry Pi. (That's what makes this issue so hard to debug.)
The take-home: if you're having issues SSHing into your headless Kali Linux Raspberry Pi, don't power your Raspberry Pi via mini USB cable to USB port. Instead, power your Raspberry Pi via USB wall adapter.
An annoying limitation, many hours wasted, but.. ok. At least it's a useful observation about the on-board hardware.