On searching for the reason for this issue, I read that it is due to a problem with the key file and most people change the ssh key to work around it. However, it is not an option for me since I have a specific openstack instance used to build this project. I am able to use this ssh key file to log into it. Any pointers as to why this issue may occur only for gitlab executor and how to resolve it?
Running with gitlab-runner 10.4.0 (857480b6)
on build config_api (7988f6db)
Using SSH executor...
ERROR: Preparation failed: asn1: structure error: superfluous leading zeros in length
Will be retried in 3s ...
Using SSH executor...
ERROR: Preparation failed: asn1: structure error: superfluous leading zeros in length
Will be retried in 3s ...
Using SSH executor...
ERROR: Preparation failed: asn1: structure error: superfluous leading zeros in length
Will be retried in 3s ...
ERROR: Job failed (system failure): asn1: structure error: superfluous leading zeros in length
The solution(or workaround) for my case was to make a new ssh key pair and add the new public key also to the authorised_keys file in the build server. With the new private key I registered my runner again and it worked.
The method I used is described in this link: Howto use multiple SSH keys for password less login