0

I've installed kali for arm on a Raspberry Pi3. The problem is I can't remotely login.

I can ping it, but trying to ssh I keep getting "connection refused". Also checked with nmap but without success.

Maybe the ssh server doesn't start at boot? How can I check and, in case, solve it from an headless setup?

I also checked the raspberry website > For headless setup, SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card. Also did this but no results

Update

looking for ssh log inside /var/log/auth.log i got this:

Jan 20 02:15:34 kali sshd[9781]: Received signal 15; terminating.
Jan 20 02:15:34 kali sshd[9832]: Server listening on 0.0.0.0 port 22.
Jan 20 02:15:34 kali sshd[9832]: Server listening on :: port 22.

Is it right to listen on 0.0.0.0? Possible missing configuration for port 22 on iptables?

Update 2

To connect everything together I set a static address for the Pi in order to connect to my pc and I set my pc as gateway, directly linked together with a patch (my pc has auto MDI-X adapter so I don't need X-cable). I can ping the Pi from my pc but, as stated before, i get "connection refused" error.

bomba
  • 3
  • 1
  • 1
  • 5

4 Answers4

4

I had the same issue some minutes ago. The issue is sourced in the fact that the Kali ARM image (in my case 2018.1 -> https://images.offensive-security.com/arm-images/kali-linux-2018.1a-rpi3-nexmon.img.xz) is shipped without ssh host keys (for a good reason!). Therefore ssh denies access - in more detail: I got a "Connection closed by 10.0.0.8 port 22" which made my curious.

To become able to access the PI without keyboard, mouse and display (this was my situation) via ssh you need to create new host keys. But how to do this headlessly?

My solution:

  1. poweroff the raspi and remove the SD-Card
  2. mount the previously written SD-Card again on a box running Linux
  3. edit /YOUR_MOUNT_POINT/etc/crontab and add the following line to the bottom of the file:
* *   * * *   root    dpkg-reconfigure openssh-server
  1. end vi, unmount the SD-Card and fire up the raspi again

What is happening here? Cron is going to execute the command "dpkg-reconfigure openssh-server" every minute. This command will create the missing host keys. And this is the trick.

If you wait at least one minute after booting your raspi again you'll be prompted with an

xxxxxxx:~ xxxxxxxx$ ssh root@10.0.0.8 The authenticity of host
'10.0.0.8 (10.0.0.8)' can't be established. ECDSA key fingerprint is
SHA256:7PF/InWST7CQgRM7FR/df41ARrIwIWco09e3yI6r2Og. Are you sure you
want to continue connecting (yes/no)?

instead of the boring

xxxxxxx:~ xxxxxxxx$ ssh root@10.0.0.8
Connection closed by 10.0.0.8 port 22

That's all :-)

As soon as you have logged in via ssh don't forget to edit /etc/crontab again and to remove the line containing "dpkg-reconfigure openssh-server" previously added. Otherwise your host keys will be re-created every minute.

user81326
  • 56
  • 2
1

The trick with the /boot/ssh file is specific to Raspbian, so it won't work on Kali. You'll have to find a way to configure your system to start sshd automatically. If you still happen to have /etc/init.d, then creating a symlink named S99sshd inside /etc/rc3.d/ and pointing to /etc/init.d/sshd should do the trick.

Otherwise, read manual pages for the init system you have on Kali to find out the way to enable a service at startup.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
-1

I have tried this approach and it works.

  1. Once you have created your image on the SSD, mount the image SSD (preferrably on a linux computer)
  2. Navigate to the /boot folder on the Kali image SSD.
  3. Use admin privileges and create a file in the /boot folder entitled ssh , with no extension. I used: $ sudo nano ssh ,type kali linux in the editor as nano will not allow you to save an empty file, then save and close the editor.
  4. Check and you should have a file called ssh in the boot folder of you SSD image file
  5. Unmount and insert into your Raspberry Pi and boot up the pi.
  6. You can access kali from ssh using $ ssh kali@[ip address] and password: kali
-1

Though it has already been answered, here is a good resource for setting up a headless RPi with Kali. I am currently running a Pi in headless mode following the guide. https://null-byte.wonderhowto.com/how-to/set-up-headless-raspberry-pi-hacking-platform-running-kali-linux-0176182/