Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I would like to implement SSH password expiry warning.

Details given below:

Using the chage command, get the next Password expiry date for admin and root user.
Read the "Number of days of warning before password expires" and raise an alarm if the current date is less than password warning days from the Expiry date.

chage -l admin

Last password change : Nov 10, 2021
Password expires : Feb 08, 2022
Password inactive : never
Account expires : never
Minimum number of days between password change : 1
Maximum number of days between password change : 90
Number of days of warning before password expires : 7

Application shall read the password warning Days stored information for any particular user and alert by raising an Alarm at 00:00 hours when the #days advance warning condition is hit for that user.
Could you please help in writing a program in C++.

Thanks in advance.

What I have tried:

Tried to use system function to run chage command and read the password expiry date.
Run localtime function and get the current time.
Posted
Updated 13-Mar-22 1:06am
Comments
Richard MacCutchan 13-Mar-22 4:25am    
"Could you please help in writing a program in C++."
Since you have not shown any of your existing code, or explained what the problem is, it is impossible to make any valid suggestions.

1 solution

The source text that was tried is missing for the question.
What you tried:
The command Running chage in a child process and getting the password expiration date from the output would be one way.
The child's output can be redirected to a pipe, which can then be evaluated in the parent process.
Further help would require your own design with source code.
 
Share this answer
 
Comments
sarali 13-Mar-22 12:39pm    
Hi,

Thanks for looking into.
I am still in the design phase hence unable to share the code.
Would it be possible to share the implementation for detecting 00:00 every day.
Any design suggestions would also help.

Thanks,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900