Test successfull ssh login

I need to verify that a ssh login is successfull, so I have to connect to a ssh server, pass username und password and then logout.
If the sshd is not working correct, there will be no prompt after passing the password.

I think it is impossible to check this with the built in ssh test, right? Is there a plugin which checks a successfull ssh login (with username/password) or do I have to write my own check?

Regards,
Peter

On Ubuntu, you would need the sshpass tool to supply a cleartext password on the command line (which is frowned upon, btw.). I don’t know about other OSes. Is that what you are looking for? Can’t you use ssh keys?
And yes, I reckon you have to write such a check yourself.

Thank you, we are using checkmk on Centos8. I can not user ssh keys, because I have to check an appliance / switch.
I will will try my very best to write a check :slight_smile:

Maybe this is not neccessary. The SSH check uses this plugin: Monitoring Plugins - check_ssh. The manpage says the tool accepts a parameter

--extra-opts=[section][@file]
    Read options from an ini file. See
    https://www.monitoring-plugins.org/doc/extra-opts.html
    for usage and examples.

and Monitoring Plugins - Extra-Opts says

The initial use case for this functionality is for hiding passwords, so you do not have to define sensitive credentials in the Nagios configuration and these options won’t appear in the command line.

Unfortunately they don’t supply a nice example of how the ini file must look like and whether it really accepts a password as parameter.

Thank you for your help, but on linux an openssh client can not use a password via parameter or a password saved in a ~/.ssh/config file. It is always interactive or you use a key without password, or an ssh agent or somethink like this.
So I will be a little tricky to solve my problem :wink:
Thank you
Regards, Peter

Yes, the regular ssh command doesn’t accept non-interactive passwords. But the check_ssh active check is an own implementation that uses its own config files. If that doesn’t work, then you probably need to use sshpass which allows for passwords on the commandline.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.