Using a custom credential in an SSHCommand probe and calling it from the shell script

johnfw
Kilo Expert

Hi Experts,

I have a SSHCommand probe that runs a shell script to launch SQLplus to connect to Oracle instances on the target server. It is working fine, but at the moment I have the Oracle user/password hard coded in the script.

Can I, and how, have the database credential stored in the custom credential table, and then call it from, or pass it to the shell script ?

Thanks in advance for any help,

john

1 ACCEPTED SOLUTION

Hey John,



Yes, you can use gs.getProperty() or gs.getMessage() to access it.



Or as you said, you can store credentials on a custom table and access it using Glide Record too.


View solution in original post

11 REPLIES 11

sudharsanv36
Kilo Guru

Hey John,



If I am not wrong, you can send the credential as a probe parameter.



On the SSH command line you will be able to access it.


Hi,



Thanks for the answer.


Yes that does work, but then the password is in plain text for anyone that looks at the probe. I was hoping to add the credential in the custom credential table and call it by id or name.


Hey John,



Yes, you can use gs.getProperty() or gs.getMessage() to access it.



Or as you said, you can store credentials on a custom table and access it using Glide Record too.


Hi,


Thanks again for the tip.


So I am now accessing the credentials table with glideRecord within a probe parameter value script.


And it is almost working. Types are now my issue.


The value script below is passed to the SSHCommand as a parameter for the shell script as ora_cred




var gr = new GlideRecord('discovery_credentials');


gr.addQuery('name', 'oracle_user');


gr.Query();


var pw_hash = gr.password;


var crypt = new GlideEncrypter();


var pw_text = crypt.decrypt(pw_hash);


answer = pw_text[0];



pw_text is typeof object, so assume it is an array. But the error from the above script is : Replaceable simple parameter 'ora_cred' doesn't exist


If I remove the array index then ora_cred becomes "org.mozilla.javascript.NativeJavaObject@..."



I'll mark your answer as correct though - this will work and is a useful tool to have once I get my types sorted out.