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

FTP client for Android handsets.
Post Reply
apska
Posts: 1
Joined: Sun Jan 17, 2021 1:47 pm
AntiSpam sum: 8

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

Post 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

dsfexy
Posts: 2
Joined: Tue Mar 01, 2022 4:49 pm
AntiSpam sum: 8

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

Post 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.

frisket
Posts: 1
Joined: Sun Aug 28, 2022 10:14 pm
AntiSpam sum: 8

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

Post 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"
Last edited by frisket on Mon Feb 10, 2025 12:12 pm, edited 1 time in total.

support
Posts: 863
Joined: Sun Apr 20, 2008 4:40 pm

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

Post by support »

Make sure to upgrade to AndFTP 6.7 and enable settings->advanced->expert->SSH Provider="Secure"

Post Reply