When using SSH, my private key is stored on my computer safely and my public key is given to the other party I wish to communicate with.
I understand that the two keys are mathematically related, and so what is encrypted with the public key can be decrypted (only) with my private key.
When I started an SSH session now, communicating with a Linux server, I received a message "Authenticating with public key "imported-openssh-key" "
What exactly is happening here to authenticate it? My guess is the server simply writes a known message to me, encrypts it with my public key. I then decrypt it on my side with my private key and send the message back to the server where it compares the message.
Is this how it works or is there something more mathematically complicated behind it?