2

Setup

  • Raspberry Pi outfitted with 64-bit Ubuntu Server 23.10 USB-SSD
  • MacBook and rPi are on the same LAN
  • rPi LAN IP address verified with ifconfig

Issue

  • From MacBook: ssh ubuntu@192.168.8.253 returns: Permission denied (publickey)

Procedure tested

enter image description here

  • restart SSH service: sudo systemctl restart ssh
  • attempts to login return the said error message
  • sudo systemtl status ssh returns active (running), but disabled
  • NEW: sudo systemctl enable ssh results:

enter image description here

QUESTIONS

  • What steps are needed to remedy the error?

Tests

  • sudo systemctl reload ssh did not solve the issue
  • ssh -vvvv ubuntu@192.168.8.253 > diagnostic.txt fails to pipe output to .txt file
  • Photograph of what should have been in diagnostic.txt:

enter image description here

gatorback
  • 5,785
  • 9
  • 40
  • 65
  • Are both the Pi and Mac on the same home network? Does the Pi have a static IP address? If not, are you using the right IP address of the Pi or are you using pi.local or something similar? Does systemctl status ssh.service say that sshd is active? If you have all these correct run the command ssh -vvvv pi_username@Pi_IP.Address and copy and paste the output in your question as code. You may want to add the answers to all these questions in your question above. – user68186 Dec 06 '23 at 22:16
  • Did you run ssh-keygen to generate a key for the host system? – Terrance Dec 06 '23 at 22:18
  • @Terrence No. I did not. I would like login with username and password: do I need to generate a key for the system host? – gatorback Dec 06 '23 at 22:40
  • You need a key for it to pair with even if you are using username and password. The key is to protect you from Man in the Middle attacks and to make sure it is authenticated with the system. Just run ssh-keygen on the Pi side. – Terrance Dec 06 '23 at 22:49
  • @Terrance. Thank you for the suggestion. I ran `ssh-keygen on the Pi side and restarted the ssh server. The error continues: "Permission Denied (publickey)". Seeking suggestions – gatorback Dec 06 '23 at 22:56
  • make sure that permissions to the keyfile are also correct. You might want to see: https://askubuntu.com/questions/311558/ssh-permission-denied-publickey – Terrance Dec 06 '23 at 22:59
  • @user68186 I have tried ssh -vvvv ubuntu@192.168.8.253 > diagnostic.txt. The screen console returns many lines of errors, however the output file is empty. Open to suggestions. – gatorback Dec 06 '23 at 23:00
  • try "sudo systemctl reload sshd" – petep Dec 06 '23 at 23:05
  • @Terrance. Please consider posting an answer with specific instructions? Having difficulty following the link. I am of the belief that the problem is on the rPi side and that the Mac side is OK because I have used the Mac to SSH into other machines with no problem – gatorback Dec 06 '23 at 23:06
  • @petep Tried / same error result. Suggestion? – gatorback Dec 06 '23 at 23:08
  • I will have to do it later when I am in front of my system and can try to duplicate your issue. But with it saying that it is a publickey error that means that it cannot see the key correctly on the server, or it is not configured properly. It is not on your Mac side. That error is server side. Maybe try reinstalling openssh-server on that system. – Terrance Dec 06 '23 at 23:08
  • I don't know anything about the Mac terminal, but in Ubuntu you can copy the text in the terminal using a mouse. Select all the text and copy using the right click context menu. Then paste it directly in your question. – user68186 Dec 06 '23 at 23:32
  • try "ssh ubuntu@192.168.8.253" on ubuntu &or ping – petep Dec 07 '23 at 00:12
  • Are you using sudo ssh ubuntu@192.168.8.253. If so don't use sudo. You should select all the text in the terminal using your mouse, then right click and copy the text. Paste the text in your question. Is your MacBook running Ubuntu? The photo of the terminal seems to suggest that. Add that information in your question. – user68186 Feb 28 '24 at 19:22

3 Answers3

2

I had the same problem with 23.10 server (raspberry pi), setting the PasswordAuthentication yes in /etc/ssh/sshd_config didn't help.

Just looking around, I noticed there is a /etc/ssh/sshd_config.d/50-cloud-init.conf, and low-and-behold, the contents of that file contain nothing but: PasswordAuthentication yes.

I deleted that file, restarted the ssh.service and was able to login with password.

No idea if some configuration will cause that file to re-appear in the future.

teeks99
  • 312
  • Mine had PasswordAuthentication no, switched it to yes, and got things working. Regardless, this is the right answer. – solenoid Mar 29 '24 at 19:21
1

These are the steps I followed to get SSH working from a remote PC to a Raspberry Pi 5 running Ubuntu 23.10

Install ssh server:

sudo apt update
sudo apt install openssh-server -y

Edit /etc/ssh/sshd_config:

PasswordAuthentication yes
PubkeyAuthentication no

Verify service is "active (running)":

sudo systemctl status ssh

Open port and/or allow ssh:

sudo ufw allow 22
sudo ufw allow ssh
yazzer
  • 111
1

Set wifi on rpi5:

sudo nano /etc/netplan/01-netcfg.yaml
network:
  version: 2
  wifis:
    wlan0:
      dhcp4: yes
      access-points:
        "your_SSID":
          password: "your_password"
      nameservers:
        addresses: [XX.XX.XX.XX, XX.XX.XX.XX]
sudo netplan apply

Set SSH:

sudo apt update
sudo apt install openssh-server -y
sudo systemctl enable ssh
sudo nano /etc/ssh/sshd_config
PasswordAuthentication to yes
KbdInteractiveAuthentication to yes
PubkeyAuthentication to no
sudo systemctl reload ssh