Cannot login via ssh before performing a local login

Hi everyone,
I just installed Ubuntu mate 16.04.2 on my raspberry pi 2. Everything was working fine, except ssh.
I then checked systemctl and found ssh was not running. Then I added /etc/init.d/ssh start to rc.local and reboot.
But I soon found that I must perform a login via keyboard directly connected to the pi after it boots up, otherwise I won’t be able to connect via ssh remotely.
Later I learned from this link that SSH is installed by default, but not turned on. You will have to enable it manually in raspi-config. So I removed the line I added in RC.local, then configured raspi-config, but still no luck, the problem is exactly the same.
Has anybody experienced this kind of issue? I tried to google but found very few results, most pointed out that it might be the fault of home directory encryption. But I didn’t enable that feature.

2 Likes

Hello @Proxy305
Can you please try this and get back to us?

The result of sudo systemctl status ssh.service looks like this…

● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab
   Active: active (running) since 二 2017-03-21 15:56:18 CST; 2h 46min ago
  Process: 1147 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCES
 Main PID: 808 (sshd)
   CGroup: /system.slice/ssh.service
           └─808 /usr/sbin/sshd -D

Seems to be fine…

And the output of ls -la /etc/systemd/system/ssh*.service:

lrwxrwxrwx 1 root root 31 Mar  21 12:45 /etc/systemd/system/sshd.service -> /lib/systemd/system/ssh.service

Then I tried sudo systemctl enable ssh.service then reboot… Still, no luck.

Well, but I noticed something interesting. Not only ssh, but also xrdp is unusable before performing a “local” login, which inspired me to think about that it might be the fault of network. The Pi 2 is connected to the network via a WiFi Dongle, which has been given static IP addr. And I tried to PINGed the Pi before “local” login, only to get some lines of “request timeout”. So it seems that the network is not ready before login. I will do more investigation on the network, and report my newest progress here as soon as possible.

Confirmed. It’s a networking problem.

I removed the WiFi Dongle from the Pi and plugged in network cable then boot. This time, I can discover the device on the lan even without a “local” login. Then I tried ssh, it was working fine.

So now I’ll have to find out what prevented the WiFi dongle to connect before login…

3 Likes

Simply go in Network Manager / Edit Connection. Select your connection, click Edit and check “Available to all users”.

Found in: https://askubuntu.com/questions/16376/connect-to-network-before-user-login

2 Likes

This is the exact solution. I was a raspbian user and had not experienced such issues with raspbian/wicd. So I did not expect that it might be the network manager setting’s fault.