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.

  • 2
    If you cannot login to the Raspbian, it's possible duplicate of SSH not working with fresh install It's unclear from where to where you try to connect! How can you expect an answer if you don't even give the most basic info? – techraf Jan 18 '17 at 23:36
  • Sorry, it seemed clear to me; it was a comparison between 2 different version: raspbian vs kali. I usualy log on my R-PIs from debian or win10 (with putty), machines, but the problem is not the host, but the PI3 with kali on it. It seems to not giving the ssh server service. Can't get why. I found this also on 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." I also did this but it doesn't work. – bomba Jan 18 '17 at 23:54
  • Please do not add information in comments. Edit your question and include the facts. It read not clear and is not clearer with your comments either. – techraf Jan 18 '17 at 23:59
  • do you advise anything more to add? – bomba Jan 19 '17 at 11:02
2

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.

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.

  • Ok, /etc/init.d is present. There's already the S02ssh file inside /etc/rc3.d/, with ../init.d/ssh in it. Could be the difference between ssh and sshd the problem? – bomba Jan 19 '17 at 15:32
  • @bomba Some distributions call SSH daemon ssh instead of sshd, so that's OK. Could you check the logs? Something like grep ssh /var/log/syslog (meaning the file on your SD card, of course). Or just open it with a text editor and search for ssh. – Dmitry Grigoryev Jan 19 '17 at 17:24
  • I updated the post with log info. – bomba Jan 20 '17 at 14:23
  • @bomba listening on 0.0.0.0 is completely normal, 0.0.0.0 means "any network address". So SSH does start, and I guess the problem is somewhere in your network. Describe how you connect everything together. – Dmitry Grigoryev Jan 20 '17 at 14:56
  • Added info. I'm going to add my iptables rules. – bomba Jan 21 '17 at 19:01
0

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/

  • The article requires you to have an HDMI cord and a wireless keyboard to first set up the Pi. How is that headless? – user8951490 Oct 14 '18 at 19:58
  • It is headless after initial configuration. You can then freely make images of the card after the initial setup if you do not wish to deal with the process again. I am not aware of a way to have Kali just automagically permit remote ssh login as part of the install process onto an SD card. It would likely require a custom image to be made on another machine first. It is just an alternative solution, and by no means the only solution. (to note, the keyboard does not have to be wireless) – Katya Veselnitskaya Oct 17 '18 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.