I've recently installed Kali linux on my Raspberry Pi 4, and I'm running into a problem that i can only ssh in after I log in to the kali user's desktop. This is an issue as I intend to run this headless most of the time.

Edit: To be more specific, before logging in, I get No route to host when trying to SSH into the device. As soon as I log into the desktop, I can connect successfully.

Edit 2: After checking journalctl -u ssh, I have found that SSH actually does start on boot, but I can only connect after logging in.

I've have enabled the ssh service using sudo systemctl enable ssh and sudo systemctl enable ssh.service, and I'm not really sure what else to do. If anyone could provide some insight towards what could be causing this, it would be greatly appreciated

  • 2
    This is odd. The first step to troubleshoot this is checking the log, i.e. journalctl -u sshd to confirm when exactly sshd is started, whether it is killed and whatever other information might be revealed. Jul 28 at 0:29
  • 2
    In particular, be careful to distinguish between the server only starting after the user logs in, versus the SSH client only successfully authenticating after the user logs in. Jul 28 at 0:45
  • @steeldriver Before logging in I get no route to host, so I'm pretty sure it's not running. I made an edit specifying this in my post. It also occured to me that it could be something with a firewall, but I haven't enabled one, and of this were the case, I wouldn't be able to SSH in whatsoever.
    – Nick
    Jul 28 at 14:42
  • @berndbausch Thanks for this suggestion! I've found that the server actually does start on boot, but I can only SSH in after logging in.
    – Nick
    Jul 28 at 14:51
  • @Nick "no route to host" actually sounds more like the interface isn't up (perhaps the interface is configured/enabled via desktop settings?) Jul 28 at 15:19

A no route to host error message means the network interface is not up and running yet.

Have you perhaps saved your network configuration as per-user settings? If so, then NetworkManager won't have access to that network configuration until you log in, and so cannot set up the network interface.

If you configure the network interface using a graphical user interface, there is usually a checkbox for "every user can use these settings", or something similar. If you check it, that network configuration will be saved as system-wide configuration, and will be usable whether or not you're logged in, allowing NetworkManager to complete network set-up during boot. But if you don't tick that box, that network configuration will be available for your user account only, requiring you to log in locally first.

This is intended mostly for making certain WiFi or VPN connections private: for example, user kiddy might only have access to an adult-content-filtered, bedtime-restricted WiFi network at home, but user daddy might also have access to a different, unrestricted "man-cave" WiFi network plus a work VPN connection. But I think the default setting when making a new network configuration is "per-user", which may come as a surprise when configuring a basic wired network connection.

If you have the settings in the form of a .nmconnection file, two steps are needed to make that connection usable system-wide without requiring any specific user to login:

  • if the connection file has a permissions= line, delete that line completely.
  • move the connection file to /etc/NetworkManager/system-connections/ directory, if it isn't already there.
  • I don't see a checkbox like that, so would I be able to do this by editing the nmconnection file for the network? The permissions field for the file is currently permissions=user:kali:;, which I'm guessing is what I have to change.
    – Nick
    Jul 28 at 15:05
  • Ok, there are so many different desktop environments and NetworkManager GUIs that my knowledge is probably out of date. But according to NetworkManager documentation, to make that connection usable by anyone, you should delete the entire permissions line, and move the connection file to /etc/NetworkManager/system-connections/ directory if it's not already there.
    – telcoM
    Jul 28 at 15:13
  • That did the trick! Thank you for the help!
    – Nick
    Jul 28 at 15:15

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.