Not being able to connect via SSH

What is the problem?
I have been using Octoprint for a long time but when i tried to install Klipper today, and i had to connect to the Raspberry Pi via SSH, the terminal gave an error message

me: ssh pi@octopi.local
pi@octopi.local: Permission denied (publickey).

What did you already try to solve it?
I tried different addresses and tried using PUTTY, i also tried putting the API key after the command.

Logs (syslog, dmesg, ... no logs, no support)

Additional information about your network (Hardware you are trying to connect to, hardware you are trying to connect from, router, access point, used operating systems, ...)

I'm using a Raspberry Pi 3b+ connected to a Elegoo Neptune 2s, the pi is connected via Ethernet.

SSH can be configured to use a username and password or it can be configured to use key pairs (one private, one public). Since we don't know what system you are trying to connect with (I'm guessing a Mac), I suggest that you google for "ssh with keys" adding your operating system.

If I flash a new image and keep the old hostname (which will probably keep the same IP address), then the first time I connect to that system I will be prompted that the identity of the system has changed. Using PuTTY from Windows, I have options to accept the new identity or abort the connection. I suggest that you google for "ssh permission denied public key" and again, add your operating system.