Tuesday, January 17, 2023

How to Create and test PEM key for OIC SFTP connections



Oracle Integration requires the keys to be in PEM format to create key based connections like SFTP connection.

That is why many a times when we get private key (OPENSSH format)to be uploaded in OIC , it fails with below error

CASDK-0004: Failed to authenticate against the application with the
credentials provided; Private Key or Passphrase is incorrect. Please verify
the Private Key and Passphrase.

as SSH keys in OPENSSH format is not supported by OIC.

The key must start with the following phrase. Oracle Integration supports keys in below format only.

-----BEGIN RSA PRIVATE KEY-----


We can generate the key in PEM format using below command

ssh-keygen -t rsa -m PEM

This will create key with default bits , if needed we can also override with -b option.




Provide the required values as it asks, and it will create private and public key.


Now let us open these files and see the format.

Private Key:




Public Key:




Now verify if this keys are related we can check the fingerprint of these keys. The fingerprint should match.

We can run below commands for private and public key respectively:

ssh-keygen -l -f id_rsa

ssh-keygen -l -f id_rsa.pub




Now we will test the keys by uploading public key to sftp,  then creating and testing connection from OIC.

Let us first upload the public key in sftp server:

We need to ensure public key is uploaded in authorized_keys and the file has correct permissions set and is under user account which we will use to create connection.

Here I will use my user sumit_kumar to create connection so I will upload public key under my user.

Login to the server:




Go to .ssh folder and do ls 



We will see authorized_keys

We will edit it to add our public key:



we can add multiple public keys here along with existing entry if any.

Copy he public key text and paste here and save the file:


We have uploaded the public key in server, now let us create the connection in OIC.

Provide the SFTP host, port etc details.

Select Security Policy as FTP Public Key Authentication.

Now upload the private key , provide the passphrase and username( under which we uploaded the public key here it is sumit_kumar)






The test will be successful:




Now if we if we provide any wrong value like different username, diff key or wrong passphrase. The test connection will fail.

Let us take example where we provide different username:

we will get error like below: