JSCH - Authentication fails with valid SSH private key
I'm trying to establish an SSH connection using Kotlin + JSch, but it fails with com.jcraft.jsch.jSchException: Auth fail. Steps taken:
Generate ssh key pair using ssh-keygen -t rsa -m PEM (OpenSSH version: OpenSSH_8.2p1)
Append contents of generated id_rsa.pub to /home/username/.ssh/authorized_keys file on the server
Test connection in the terminal: ssh -i /path/to/id_rsa
username@example.host.com - works fine
Execute the following Kotlin code:
import com.jcraft.jsch.JSch
const val USER =...