Question
· Jul 11, 2018

SSH Authentication error - "Invalid key data, not base64 encoded"

Hi,

We are having an issue with the class %Net.SSH.Session - it accepts a username, publicKeyFile, privateKeyFile and passPhrase.

This is our example code:

            set ssh = ##class(%Net.SSH.Session).%New()

            set tSC = ssh.Connect("172.10.10.1", 22)

            $$$ThrowOnError(tSC)

           

            set Username = "a"

            set passphrase = "123"

            set pub = "C:\FTPServer\pubkey\publicKey.pub"           

            set priv = "C:\FTPServer\private.key"

           

            set tSC = ssh.AuthenticateWithKeyPair(Username,pub,priv,passphrase)

            $$$ThrowOnError(tSC)

 

We are getting the following error:

ERROR #7500: SSH AuthenticateWithKeyPair Error '-2146430960': SSH Error [80101010]: Invalid key data, not base64 encoded [80101010] at Session.cpp:313,0

 

We have generated our RSA public / private keys  in an OpenSSH format using PuttyGen.

Any help on this would be appreciated.

Discussion (6)0
Log in or sign up to continue

OpenSSH format is the correct public key format, so your format should be ok.  The private key should be PEM encoded.

I've seen this happen sometimes when the key is in the correct format but the file has extra blank space in it, so I'd recommend making sure the key is all on one line with no white space or line breaks.  Whether this should matter is debated, but it's easy to to check.

This error is coming from the libssh2 library, so if you want to research it further, you could look into other people using that library who've seen it. 

Thanks for your reply.

We have tried formatting the private key as one line. However, we do not think its getting that far as its failing on the public key stage. 

Here is an example public key / private key that we are generating (test purposes only):

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-testkey"
AAAAB3NzaC1yc2EAAAABJQAAAQEAhNIpZ7HqZb3WRQmSn93OElEK5v3vYO5KJdfS
/5acJdTUvSYS+xn3wf56OLCvmgBsm8B7kc988lqYO90OH4hCR2UwpvG/wDRv0qyw
INWJTX/9UGASZmgLiKf3WdW+JmOrgwOiANAvb00U2Judp82JiOLzMF4VAeJYsDeJ
tbUyneEOct711LFpFItU9Fk/DsdeEaK13ZyOUFNX2FK6gC1sgqbFTv5TIHUA1A7h
tKmcfP3mYu6K6mwgknxLHBfd0Qj8a6ak4L8kAgG0G251K7Jf7vIdKPl+hfeH4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