Page 1 of 1

SFTP Public key authentication failure: Invalid PEM structure, ----BEGIN..... missing?

Posted: Sun Jan 17, 2021 2:21 pm
by apska
Hi Support,

I have been using AndFTP for many years for syncing data from my mobile phone to my Ubuntu server. Also public key authentication has worked, at least with the free version. Now I'm running AndFTP 5.4 Pro version and a new server instance. I have an issue with SFTP and public key authentication.

Attempting to connect using SFTP with custom SSH port 2222. Server (Ubuntu 20.04) does not allow password logins. I have created a pair of RSA keys with ssh-keygen. Public key has been added to the server authorized_keys. Private key available in the mobile device.

Thus AndFTP settings look like this:
settings_general.png
settings_advanced.png
When trying to connect, I get error saying Publickey authentication failed. java.io.IOException: Invalid PEM structure, '-----BEGIN...' missing
connect_error_message.png
The key file starts with

Code: Select all

-----BEGIN OPENSSH PRIVATE KEY-----
and definitely seems correct to me.

Could you please check if it should be possible to connect with these conditions? Thanks!

AndFTP 5.4 Pro
Android 10 on Nokia 8.1 TA-1119

Re: SFTP Public key authentication failure: Invalid PEM structure, ----BEGIN..... missing?

Posted: Wed Mar 02, 2022 2:03 pm
by dsfexy
Having seen another post about ed25519 support, I've found the following.

With a 2048bit RSA key, and settings->advanced->expert->SSH Provider=default I get the failure / error reported above.

If I change settings->advanced->expert->SSH Provider="Secure (includes ED25519)" then the login is successful.

Re: SFTP Public key authentication failure: Invalid PEM structure, ----BEGIN..... missing?

Posted: Mon Feb 10, 2025 12:09 pm
by frisket
I am in a similar position: new phone (Goole Pixel 8a), new laptop (Mint 22). All my old sftp hosts still work in AndFTP, but the new one simply rejects the username/password. I suspect it's looking to perform the host id dialog, but nothing gets popped up in AndFTP. Are there logs anywhere that would help me fix the error? All I can see is at the bottom of the screen "Key exchange was not finished"

Re: SFTP Public key authentication failure: Invalid PEM structure, ----BEGIN..... missing?

Posted: Mon Aug 11, 2025 12:20 pm
by support
Make sure to upgrade to AndFTP 6.7 and enable settings->advanced->expert->SSH Provider="Secure"